Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f038374

Browse files
committed
init repo
0 parents  commit f038374

File tree

13 files changed

+281
-0
lines changed

13 files changed

+281
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea/
2+
vendor/

autoload.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
namespace WebLinuxGame\Utils;
4+
5+
require_once __DIR__.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';

composer.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "weblinuxgame/utils",
3+
"description": "helper utils",
4+
"type": "library",
5+
"license": "MTI",
6+
"authors": [
7+
{
8+
"name": "weblinuxgame",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"autoload": {
13+
"psr-4": {
14+
"WebLinuxGame\\": "./src"
15+
}
16+
},
17+
"minimum-stability": "dev",
18+
"require": {}
19+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: weblinuxgame
5+
* Date: 2018/11/11
6+
* Time: 20:15
7+
*/
8+
9+
namespace WebLinuxGame\Utils\Helper\Factory;
10+
11+
use WebLinuxGame\Utils\Helper\Traits\BusinessCode;
12+
13+
abstract class ResponseBusinessCode
14+
{
15+
use BusinessCode;
16+
17+
public static function __callStatic($name, $arguments)
18+
{
19+
20+
}
21+
}

src/Utils/Helper/Factory/Type.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace WebLinuxGame\Utils\Helper\Factory;
4+
5+
use WebLinuxGame\Utils\Helper\Traits\ArrTrait;
6+
7+
use WebLinuxGame\Utils\Helper\Interfaces\TypeInterface;
8+
9+
/**
10+
* 类型工厂
11+
* Class Type
12+
* @package WebLinuxGame\Utils\Helper\Factory
13+
*/
14+
class Type implements TypeInterface
15+
{
16+
17+
use ArrTrait;
18+
19+
public static function type(string $type, $data = null)
20+
{
21+
$method = static::callByStr($type, 'is');
22+
if (method_exists(self::class, $method)) {
23+
return self::$method($data);
24+
}
25+
return false;
26+
}
27+
28+
protected static function callByStr(string $name = '', string $prefix = '')
29+
{
30+
if (empty($name)) {
31+
return null;
32+
}
33+
if (empty($prefix)) {
34+
return $name;
35+
}
36+
return $prefix . ucfirst($name);
37+
}
38+
39+
40+
public static function make()
41+
{
42+
43+
}
44+
45+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace WebLinuxGame\Utils\Helper\Interfaces;
4+
5+
/**
6+
* 类型检查器接口
7+
* @desc 检查数据对象类型
8+
* @autor weblinuxgame
9+
* @time 2018.11.10
10+
*/
11+
12+
interface TypeInterface
13+
{
14+
public static function type(string $type,$data = null);
15+
}
16+
17+
18+
19+

src/Utils/Helper/Traits/ArrTrait.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
namespace WebLinuxGame\Utils\Helper\Traits;
3+
4+
5+
trait ArrTrait
6+
{
7+
use IntegerArrTrait;
8+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: weblinuxgame
5+
* Date: 2018/11/12
6+
* Time: 10:01
7+
*/
8+
9+
namespace WebLinuxGame\Utils\Helper\Traits;
10+
11+
12+
trait BusinessCode
13+
{
14+
15+
protected static $businessConfig = [];
16+
17+
public static function loadConfig(string $file = '')
18+
{
19+
if(empty($file)){
20+
$file = '';
21+
}
22+
$config = [];
23+
foreach ($config as $module => $item) {
24+
if (empty($item)) {
25+
continue;
26+
}
27+
if (empty(static::$businessConfig['code'])) {
28+
static::$businessConfig['code'] = [];
29+
}
30+
if (static::uniqueness($item['name'], $item['code'], $item['msg'])) {
31+
$id = count(static::$businessConfig['code']);
32+
array_push(static::$businessConfig['code'], $item);
33+
static::$businessConfig[$module] = $id;
34+
}
35+
}
36+
}
37+
38+
protected static function uniqueness(string $name = '', int $code = null, string $msg = '')
39+
{
40+
return true;
41+
}
42+
43+
protected static function __code(string $name = '', string $attr = '')
44+
{
45+
return false;
46+
}
47+
48+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace WebLinuxGame\Utils\Helper\Traits;
4+
5+
/**
6+
* @desc: 整型数组
7+
*/
8+
trait IntegerArrTrait
9+
{
10+
public static function intArr(...$args)
11+
{
12+
$argc = func_num_args();
13+
if(0 ==$argc){
14+
return null ;
15+
}
16+
$argv = func_get_args();
17+
$filter = function($v){
18+
return is_int($v);
19+
};
20+
if(1 == $argc){
21+
if(is_numeric($argv[0]) && is_integer($argv[0])){
22+
return array($argv[0]);
23+
}
24+
if(is_array($argv[0])){
25+
$data = array_filter($argv[0],$filter,ARRAY_FILTER_USE_BOTH);
26+
if(!empty($data)){
27+
return $data;
28+
}
29+
}
30+
}
31+
return array_filter($argv,$filter,ARRAY_FILTER_USE_BOTH);
32+
}
33+
34+
public static function isIntArr($data = null)
35+
{
36+
if(empty($data) || !is_array($data)){
37+
return false;
38+
}
39+
foreach($data as $it){
40+
if(!is_int($it)){
41+
return false;
42+
}
43+
}
44+
return true;
45+
}
46+
}

src/config/code.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: weblinuxgame
5+
* Date: 2018/11/12
6+
* Time: 10:20
7+
*/
8+
9+
return [
10+
'module_name' => [
11+
[
12+
'msg' => '',
13+
'name' => '',
14+
'code' => 200,
15+
],
16+
[
17+
'msg' => '',
18+
'name' => '',
19+
'code' => 200,
20+
],
21+
[
22+
'msg' => '',
23+
'name' => '',
24+
'code' => 200,
25+
],
26+
],
27+
28+
];

0 commit comments

Comments
 (0)