Passed
Push — master ( 472e0b...efc763 )
by Aleksandr
02:00
created
src/request/OrderRequest.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
 			'action' => 'create_order'
81 81
 		];
82 82
 		foreach (($config instanceof \carono\turbotext\ConfigAbstract ? $config->toArray() : $config) as $key => $value) {
83
-		    $params[$key] = $value;
83
+			$params[$key] = $value;
84 84
 		}
85 85
 		return $this->getClient()->getContent('api', $params, 'carono\turbotext\response\CreateOrderResponse');
86 86
 	}
Please login to merge, or discard this patch.
src/request/MicroTaskRequest.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
 			'action' => 'create_microtask'
67 67
 		];
68 68
 		foreach (($config instanceof \carono\turbotext\ConfigAbstract ? $config->toArray() : $config) as $key => $value) {
69
-		    $params[$key] = $value;
69
+			$params[$key] = $value;
70 70
 		}
71 71
 		return $this->getClient()->getContent('api', $params, 'carono\turbotext\response\CreateMicrotaskResponse');
72 72
 	}
Please login to merge, or discard this patch.
codegen/generate.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -15,49 +15,49 @@
 block discarded – undo
15 15
 clearFolder('response');
16 16
 
17 17
 $sections = [
18
-    'api1' => 'order',
19
-    'api2' => 'user',
20
-    'api3' => 'microTask',
21
-    'api4' => 'message',
18
+	'api1' => 'order',
19
+	'api2' => 'user',
20
+	'api3' => 'microTask',
21
+	'api4' => 'message',
22 22
 ];
23 23
 $apidoc = 'apidoc.html';
24 24
 if (file_exists($apidoc)) {
25
-    $content = file_get_contents($apidoc);
25
+	$content = file_get_contents($apidoc);
26 26
 } else {
27
-    $content = (new Client())->get('https://www.turbotext.ru/api-info/')->getBody()->getContents();
28
-    file_put_contents($apidoc, $content);
27
+	$content = (new Client())->get('https://www.turbotext.ru/api-info/')->getBody()->getContents();
28
+	file_put_contents($apidoc, $content);
29 29
 }
30 30
 $query = \phpQuery::newDocumentHTML($content);
31 31
 $data = [];
32 32
 $i = 1;
33 33
 foreach ($desc = $query->find('.api_descr') as $desc) {
34
-    $h3 = pq($desc)->prev('h3')->text();
35
-    $item = [
36
-        'name' => $sections['api' . $i++],
37
-        'description' => $h3,
38
-        'methods' => []
39
-    ];
40
-    foreach (pq($desc)->find('table tr') as $tr) {
41
-        $tr = pq($tr);
42
-        if (!$name = trim($tr->find('td')->eq(0)->text())) {
43
-            continue;
44
-        }
45
-        $params = [];
46
-        foreach ($tr->find('td')->eq(2)->find('li') as $param) {
47
-            if ($parsedParam = parseParams(pq($param)->text())) {
48
-                $params[] = $parsedParam;
49
-            }
50
-        }
51
-        $returns = parseReturns($uls = $tr->find('td')->eq(3)->htmlOuter());
52
-        $method = [
53
-            'name' => $name,
54
-            'description' => $tr->find('td')->eq(1)->text(),
55
-            'params' => $params,
56
-            'returns' => $returns
57
-        ];
58
-        $item['methods'][] = $method;
59
-    }
60
-    $data[] = $item;
34
+	$h3 = pq($desc)->prev('h3')->text();
35
+	$item = [
36
+		'name' => $sections['api' . $i++],
37
+		'description' => $h3,
38
+		'methods' => []
39
+	];
40
+	foreach (pq($desc)->find('table tr') as $tr) {
41
+		$tr = pq($tr);
42
+		if (!$name = trim($tr->find('td')->eq(0)->text())) {
43
+			continue;
44
+		}
45
+		$params = [];
46
+		foreach ($tr->find('td')->eq(2)->find('li') as $param) {
47
+			if ($parsedParam = parseParams(pq($param)->text())) {
48
+				$params[] = $parsedParam;
49
+			}
50
+		}
51
+		$returns = parseReturns($uls = $tr->find('td')->eq(3)->htmlOuter());
52
+		$method = [
53
+			'name' => $name,
54
+			'description' => $tr->find('td')->eq(1)->text(),
55
+			'params' => $params,
56
+			'returns' => $returns
57
+		];
58
+		$item['methods'][] = $method;
59
+	}
60
+	$data[] = $item;
61 61
 };
62 62
 file_put_contents('data.json', json_encode($data));
63 63
 
Please login to merge, or discard this patch.
codegen/ConfigAbstract.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
 
8 8
 class ConfigAbstract extends ClassGenerator
9 9
 {
10
-    protected function formExtends()
11
-    {
12
-        return 'carono\turbotext\ConfigAbstract';
13
-    }
14
-
15
-    protected function formClassName()
16
-    {
17
-        return formClassName($this->params['name'], ['get_', '_array', 'create_']) . 'Config';
18
-    }
19
-
20
-    protected function formClassNamespace()
21
-    {
22
-        return 'carono\turbotext\config';
23
-    }
24
-
25
-    protected function formOutputPath()
26
-    {
27
-        return dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . $this->formClassName() . '.php';
28
-    }
29
-
30
-    protected function classProperties()
31
-    {
32
-        $properties = [];
33
-        foreach ($this->params['params'] as $param) {
34
-            if (is_string($param)) {
35
-                continue;
36
-            }
37
-            $properties[$param['name']] = [
38
-                'comment' => [
39
-                    stripAndWordWrap(stripSpaces($param['description'])),
40
-                    '@var ' . formParamType($param['type'])
41
-                ]
42
-            ];
43
-        }
44
-        return $properties;
45
-    }
10
+	protected function formExtends()
11
+	{
12
+		return 'carono\turbotext\ConfigAbstract';
13
+	}
14
+
15
+	protected function formClassName()
16
+	{
17
+		return formClassName($this->params['name'], ['get_', '_array', 'create_']) . 'Config';
18
+	}
19
+
20
+	protected function formClassNamespace()
21
+	{
22
+		return 'carono\turbotext\config';
23
+	}
24
+
25
+	protected function formOutputPath()
26
+	{
27
+		return dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . $this->formClassName() . '.php';
28
+	}
29
+
30
+	protected function classProperties()
31
+	{
32
+		$properties = [];
33
+		foreach ($this->params['params'] as $param) {
34
+			if (is_string($param)) {
35
+				continue;
36
+			}
37
+			$properties[$param['name']] = [
38
+				'comment' => [
39
+					stripAndWordWrap(stripSpaces($param['description'])),
40
+					'@var ' . formParamType($param['type'])
41
+				]
42
+			];
43
+		}
44
+		return $properties;
45
+	}
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
codegen/func.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -1,124 +1,124 @@
 block discarded – undo
1 1
 <?php
2 2
 function clearFolder($folder)
3 3
 {
4
-    $files = glob(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . '*');
5
-    foreach ($files as $file) {
6
-        if (is_file($file)) {
7
-            @unlink($file);
8
-        }
9
-    }
4
+	$files = glob(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . '*');
5
+	foreach ($files as $file) {
6
+		if (is_file($file)) {
7
+			@unlink($file);
8
+		}
9
+	}
10 10
 }
11 11
 
12 12
 function stripAndWordWrap($str)
13 13
 {
14
-    return wordwrap(stripSpaces($str), 180) . "\n";
14
+	return wordwrap(stripSpaces($str), 180) . "\n";
15 15
 }
16 16
 
17 17
 function formParamLine($param)
18 18
 {
19
-    return '**' . $param['name'] . "** ({$param['type']}) - " . stripLines($param['description']);
19
+	return '**' . $param['name'] . "** ({$param['type']}) - " . stripLines($param['description']);
20 20
 }
21 21
 
22 22
 function stripSpaces($str)
23 23
 {
24
-    $str = preg_replace('/[\s]{2,}/', " ", $str);
25
-    return $str;
24
+	$str = preg_replace('/[\s]{2,}/', " ", $str);
25
+	return $str;
26 26
 }
27 27
 
28 28
 function stripLines($str)
29 29
 {
30
-    $str = str_replace("\n", " ", $str);
31
-    $str = stripSpaces($str);
32
-    return $str;
30
+	$str = str_replace("\n", " ", $str);
31
+	$str = stripSpaces($str);
32
+	return $str;
33 33
 }
34 34
 
35 35
 function formMethodName($str)
36 36
 {
37
-    $arr = array_filter(explode('_', $str));
38
-    $arr = array_map('ucfirst', $arr);
39
-    $arr[0] = lcfirst($arr[0]);
40
-    return join('', $arr);
37
+	$arr = array_filter(explode('_', $str));
38
+	$arr = array_map('ucfirst', $arr);
39
+	$arr[0] = lcfirst($arr[0]);
40
+	return join('', $arr);
41 41
 }
42 42
 
43 43
 function formClassName($str, $clear = ['get_', '_array'])
44 44
 {
45
-    foreach ($clear as $item) {
46
-        $str = str_ireplace($item, '', $str);
47
-    }
48
-    $arr = array_filter(explode('_', $str));
49
-    $arr = array_map('ucfirst', $arr);
50
-    return join('', $arr);
45
+	foreach ($clear as $item) {
46
+		$str = str_ireplace($item, '', $str);
47
+	}
48
+	$arr = array_filter(explode('_', $str));
49
+	$arr = array_map('ucfirst', $arr);
50
+	return join('', $arr);
51 51
 }
52 52
 
53 53
 function formParamType($str)
54 54
 {
55
-    if ($str == 'text') {
56
-        return 'string';
57
-    }
58
-    return $str;
55
+	if ($str == 'text') {
56
+		return 'string';
57
+	}
58
+	return $str;
59 59
 }
60 60
 
61 61
 function parseParams($str)
62 62
 {
63
-    if (preg_match('/^(\w+)\s+\((\w+)\)\s+-\s+(.+)/uis', $str, $m)) {
64
-        return [
65
-            'name' => $m[1],
66
-            'type' => $m[2],
67
-            'description' => $m[3],
68
-            'required' => mb_strpos($m[3], 'Необязательный', 0, 'utf-8') === false
69
-        ];
70
-    } else {
71
-        return [];
72
-    }
63
+	if (preg_match('/^(\w+)\s+\((\w+)\)\s+-\s+(.+)/uis', $str, $m)) {
64
+		return [
65
+			'name' => $m[1],
66
+			'type' => $m[2],
67
+			'description' => $m[3],
68
+			'required' => mb_strpos($m[3], 'Необязательный', 0, 'utf-8') === false
69
+		];
70
+	} else {
71
+		return [];
72
+	}
73 73
 }
74 74
 
75 75
 function parseReturns($tdHtml)
76 76
 {
77
-    $uls = pq($tdHtml)->find('ul');
78
-    $returns = [];
79
-    if ($uls->count() == 1 && strpos($tdHtml, 'Каждый элемент') !== false) {
80
-        if (preg_match('/<td>(.)+<ul>/s', $tdHtml, $m)) {
81
-            $ul = "<ul><li>" . trim(strip_tags($m[0])) . "</li></ul>";
82
-            $uls = pq("<td>$ul{$uls->eq(0)->htmlOuter()}</td>")->find('ul');
83
-        }
84
-    }
85
-    if ($uls->count() == 2) {
86
-        $returnParam = parseParams($uls->eq(0)->text());
87
-        $result = [];
88
-        foreach ($uls->eq(1)->find('li') as $param) {
89
-            if ($parsedParam = parseParams(pq($param)->text())) {
90
-                $result[] = $parsedParam;
91
-            }
92
-        }
93
-        $returnParam['result'] = $result;
94
-        $returns[] = $returnParam;
95
-    } else {
96
-        foreach ($uls->eq(0)->find('li') as $param) {
97
-            if ($parsedParam = parseParams(pq($param)->text())) {
98
-                $returns[] = $parsedParam;
99
-            }
100
-        }
101
-    }
102
-    return $returns;
77
+	$uls = pq($tdHtml)->find('ul');
78
+	$returns = [];
79
+	if ($uls->count() == 1 && strpos($tdHtml, 'Каждый элемент') !== false) {
80
+		if (preg_match('/<td>(.)+<ul>/s', $tdHtml, $m)) {
81
+			$ul = "<ul><li>" . trim(strip_tags($m[0])) . "</li></ul>";
82
+			$uls = pq("<td>$ul{$uls->eq(0)->htmlOuter()}</td>")->find('ul');
83
+		}
84
+	}
85
+	if ($uls->count() == 2) {
86
+		$returnParam = parseParams($uls->eq(0)->text());
87
+		$result = [];
88
+		foreach ($uls->eq(1)->find('li') as $param) {
89
+			if ($parsedParam = parseParams(pq($param)->text())) {
90
+				$result[] = $parsedParam;
91
+			}
92
+		}
93
+		$returnParam['result'] = $result;
94
+		$returns[] = $returnParam;
95
+	} else {
96
+		foreach ($uls->eq(0)->find('li') as $param) {
97
+			if ($parsedParam = parseParams(pq($param)->text())) {
98
+				$returns[] = $parsedParam;
99
+			}
100
+		}
101
+	}
102
+	return $returns;
103 103
 }
104 104
 
105 105
 function asTable($array)
106 106
 {
107
-    $header = array_shift($array);
108
-    $content = "\n\n|" . join("|", $header) . "\n";
109
-    $content .= preg_replace('/[^\|]/iu', '-', trim($content)) . "\n";
110
-    foreach ($array as $key => $columns) {
111
-        $content .= "|" . join("|", $columns) . "\n";
112
-    }
113
-    return $content;
107
+	$header = array_shift($array);
108
+	$content = "\n\n|" . join("|", $header) . "\n";
109
+	$content .= preg_replace('/[^\|]/iu', '-', trim($content)) . "\n";
110
+	foreach ($array as $key => $columns) {
111
+		$content .= "|" . join("|", $columns) . "\n";
112
+	}
113
+	return $content;
114 114
 }
115 115
 
116 116
 function asHeader($string)
117 117
 {
118
-    return "\n\n" . $string . "\n" . str_repeat('=', mb_strlen($string, 'utf-8')) . "\n";
118
+	return "\n\n" . $string . "\n" . str_repeat('=', mb_strlen($string, 'utf-8')) . "\n";
119 119
 }
120 120
 
121 121
 function asCode($code)
122 122
 {
123
-    return "`$code`";
123
+	return "`$code`";
124 124
 }
125 125
\ No newline at end of file
Please login to merge, or discard this patch.