Passed
Push — master ( aa38b9...a9307f )
by Aleksandr
03:34
created
src/request/OrderRequest.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 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
 	}
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 			'action' => 'create_translate_order'
99 99
 		];
100 100
 		foreach (($config instanceof \carono\turbotext\ConfigAbstract ? $config->toArray() : $config) as $key => $value) {
101
-		    $params[$key] = $value;
101
+			$params[$key] = $value;
102 102
 		}
103 103
 		return $this->getClient()->getContent('api', $params, 'carono\turbotext\response\CreateTranslateOrderResponse');
104 104
 	}
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 			'action' => 'edit_order'
274 274
 		];
275 275
 		foreach (($config instanceof \carono\turbotext\ConfigAbstract ? $config->toArray() : $config) as $key => $value) {
276
-		    $params[$key] = $value;
276
+			$params[$key] = $value;
277 277
 		}
278 278
 		return $this->getClient()->getContent('api', $params, 'carono\turbotext\Response');
279 279
 	}
Please login to merge, or discard this patch.
codegen/RequestAbstract.php 1 patch
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -6,110 +6,110 @@
 block discarded – undo
6 6
 
7 7
 class RequestAbstract extends ClassGenerator
8 8
 {
9
-    /**
10
-     * @return string
11
-     */
12
-    protected function formExtends()
13
-    {
14
-        return 'carono\turbotext\RequestAbstract';
15
-    }
9
+	/**
10
+	 * @return string
11
+	 */
12
+	protected function formExtends()
13
+	{
14
+		return 'carono\turbotext\RequestAbstract';
15
+	}
16 16
 
17
-    /**
18
-     * @return string
19
-     */
20
-    protected function formClassName()
21
-    {
22
-        return ucfirst($this->params['name']) . 'Request';
23
-    }
17
+	/**
18
+	 * @return string
19
+	 */
20
+	protected function formClassName()
21
+	{
22
+		return ucfirst($this->params['name']) . 'Request';
23
+	}
24 24
 
25
-    /**
26
-     * @return string
27
-     */
28
-    protected function formClassNamespace()
29
-    {
30
-        return 'carono\turbotext\request';
31
-    }
25
+	/**
26
+	 * @return string
27
+	 */
28
+	protected function formClassNamespace()
29
+	{
30
+		return 'carono\turbotext\request';
31
+	}
32 32
 
33
-    /**
34
-     * @return string
35
-     */
36
-    protected function formOutputPath()
37
-    {
38
-        return dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'request' . DIRECTORY_SEPARATOR . $this->formClassName() . '.php';
39
-    }
33
+	/**
34
+	 * @return string
35
+	 */
36
+	protected function formOutputPath()
37
+	{
38
+		return dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'request' . DIRECTORY_SEPARATOR . $this->formClassName() . '.php';
39
+	}
40 40
 
41
-    /**
42
-     * @return bool
43
-     */
44
-    public function methods()
45
-    {
46
-        foreach ($this->params['methods'] as $methodData) {
47
-            $methodName = formMethodName($methodData['name']);
48
-            $method = $this->phpClass->addMethod($methodName);
49
-            $method->addComment(stripAndWordWrap($methodData['description']));
50
-            $params = [];
51
-            $params['action'] = $methodData['name'];
52
-            if (count($methodData['params']) > 4) {
53
-                $config = new ConfigAbstract();
54
-                $config->renderToFile($methodData);
55
-                $className = '\\' . $config->formClassNamespace() . '\\' . $config->formClassName();
56
-                $method->addParameter('config');
57
-                $method->addComment("@param $className|array \$config");
41
+	/**
42
+	 * @return bool
43
+	 */
44
+	public function methods()
45
+	{
46
+		foreach ($this->params['methods'] as $methodData) {
47
+			$methodName = formMethodName($methodData['name']);
48
+			$method = $this->phpClass->addMethod($methodName);
49
+			$method->addComment(stripAndWordWrap($methodData['description']));
50
+			$params = [];
51
+			$params['action'] = $methodData['name'];
52
+			if (count($methodData['params']) > 4) {
53
+				$config = new ConfigAbstract();
54
+				$config->renderToFile($methodData);
55
+				$className = '\\' . $config->formClassNamespace() . '\\' . $config->formClassName();
56
+				$method->addParameter('config');
57
+				$method->addComment("@param $className|array \$config");
58 58
 
59
-                $body = <<<PHP
59
+				$body = <<<PHP
60 60
 foreach ((\$config instanceof \carono\\turbotext\ConfigAbstract ? \$config->toArray() : \$config) as \$key => \$value) {
61 61
     \$params[\$key] = \$value;
62 62
 }
63 63
 PHP;
64
-                $paramsStr = self::arrayAsPhpVar($params);
65
-                $method->addBody("\$params = $paramsStr;");
66
-                $method->addBody($body);
67
-            } else {
68
-                foreach ($methodData['params'] as $param) {
69
-                    $type = formParamType($param['type']);
70
-                    $description = trim(stripAndWordWrap($param['description']));
71
-                    $method->addComment("@param {$type} \${$param['name']} {$description}");
72
-                    $params[$param['name']] = '$' . $param['name'];
73
-                    if ($param['required']) {
74
-                        $method->addParameter($param['name']);
75
-                    } else {
76
-                        $method->addParameter($param['name'], null);
77
-                    }
78
-                }
79
-                $paramsStr = self::arrayAsPhpVar($params);
80
-                $method->addBody("\$params = $paramsStr;");
81
-            }
82
-            $response = new ResponseAbstract();
83
-            if (isset($methodData['returns'][0]['result'])) {
84
-                $returns = $methodData['returns'][0];
85
-                $response->renderToFile($returns);
86
-                $className = $response->formClassNamespace() . '\\' . $response->formClassName();
87
-            } elseif ($methodData['returns']) {
88
-                $methodData['returns']['name'] = $methodData['name'];
89
-                $response->properties['asd'] = 213;
90
-                $response->renderToFile($methodData['returns']);
91
-                $className = $response->formClassNamespace() . '\\' . $response->formClassName();
92
-            } else {
93
-                $className = 'carono\turbotext\Response';
94
-            }
95
-            $method->addComment("@return \\$className|string|\stdClass|\SimpleXMLElement");
96
-            $method->addBody("return \$this->getClient()->getContent('api', \$params, '$className');");
97
-        }
98
-        return false;
99
-    }
64
+				$paramsStr = self::arrayAsPhpVar($params);
65
+				$method->addBody("\$params = $paramsStr;");
66
+				$method->addBody($body);
67
+			} else {
68
+				foreach ($methodData['params'] as $param) {
69
+					$type = formParamType($param['type']);
70
+					$description = trim(stripAndWordWrap($param['description']));
71
+					$method->addComment("@param {$type} \${$param['name']} {$description}");
72
+					$params[$param['name']] = '$' . $param['name'];
73
+					if ($param['required']) {
74
+						$method->addParameter($param['name']);
75
+					} else {
76
+						$method->addParameter($param['name'], null);
77
+					}
78
+				}
79
+				$paramsStr = self::arrayAsPhpVar($params);
80
+				$method->addBody("\$params = $paramsStr;");
81
+			}
82
+			$response = new ResponseAbstract();
83
+			if (isset($methodData['returns'][0]['result'])) {
84
+				$returns = $methodData['returns'][0];
85
+				$response->renderToFile($returns);
86
+				$className = $response->formClassNamespace() . '\\' . $response->formClassName();
87
+			} elseif ($methodData['returns']) {
88
+				$methodData['returns']['name'] = $methodData['name'];
89
+				$response->properties['asd'] = 213;
90
+				$response->renderToFile($methodData['returns']);
91
+				$className = $response->formClassNamespace() . '\\' . $response->formClassName();
92
+			} else {
93
+				$className = 'carono\turbotext\Response';
94
+			}
95
+			$method->addComment("@return \\$className|string|\stdClass|\SimpleXMLElement");
96
+			$method->addBody("return \$this->getClient()->getContent('api', \$params, '$className');");
97
+		}
98
+		return false;
99
+	}
100 100
 
101
-    protected static function arrayAsPhpVar($array)
102
-    {
103
-        $export = [];
104
-        foreach ($array as $key => $value) {
105
-            $export[] = "'$key' => " . (strpos($value, '$') === false ? "'$value'" : $value);
106
-        }
107
-        $export = join(",\n\t", $export);
108
-        if ($array) {
109
-            $result = "[\n\t$export\n]";
110
-        } else {
111
-            $result = "[]";
112
-        }
113
-        return $result;
114
-    }
101
+	protected static function arrayAsPhpVar($array)
102
+	{
103
+		$export = [];
104
+		foreach ($array as $key => $value) {
105
+			$export[] = "'$key' => " . (strpos($value, '$') === false ? "'$value'" : $value);
106
+		}
107
+		$export = join(",\n\t", $export);
108
+		if ($array) {
109
+			$result = "[\n\t$export\n]";
110
+		} else {
111
+			$result = "[]";
112
+		}
113
+		return $result;
114
+	}
115 115
 }
116 116
\ No newline at end of file
Please login to merge, or discard this patch.
codegen/ClientAbstract.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -6,42 +6,42 @@
 block discarded – undo
6 6
 
7 7
 class ClientAbstract extends ClassGenerator
8 8
 {
9
-    protected function formExtends()
10
-    {
11
-        return 'carono\rest\Client';
12
-    }
9
+	protected function formExtends()
10
+	{
11
+		return 'carono\rest\Client';
12
+	}
13 13
 
14
-    protected function formClassName()
15
-    {
16
-        return 'ClientAbstract';
17
-    }
14
+	protected function formClassName()
15
+	{
16
+		return 'ClientAbstract';
17
+	}
18 18
 
19
-    protected function formClassNamespace()
20
-    {
21
-        return 'carono\turbotext';
22
-    }
19
+	protected function formClassNamespace()
20
+	{
21
+		return 'carono\turbotext';
22
+	}
23 23
 
24
-    protected function formOutputPath()
25
-    {
26
-        return dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $this->formClassName() . '.php';
27
-    }
24
+	protected function formOutputPath()
25
+	{
26
+		return dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $this->formClassName() . '.php';
27
+	}
28 28
 
29
-    public function methods()
30
-    {
31
-        $this->phpClass->setAbstract(true);
32
-        foreach ($this->params as $section) {
33
-            $sectionRequest = new RequestAbstract();
34
-            $sectionRequest->renderToFile($section);
35
-            $className = "\\" . $sectionRequest->formClassNamespace() . "\\" . $sectionRequest->formClassName();
36
-            $method = $this->phpClass->addMethod($section['name']);
37
-            $body = <<<PHP
29
+	public function methods()
30
+	{
31
+		$this->phpClass->setAbstract(true);
32
+		foreach ($this->params as $section) {
33
+			$sectionRequest = new RequestAbstract();
34
+			$sectionRequest->renderToFile($section);
35
+			$className = "\\" . $sectionRequest->formClassNamespace() . "\\" . $sectionRequest->formClassName();
36
+			$method = $this->phpClass->addMethod($section['name']);
37
+			$body = <<<PHP
38 38
 return (new $className(\$this));
39 39
 PHP;
40
-            $method->addBody($body);
41
-            $method->addComment($section['description']);
42
-            $method->addComment('');
43
-            $method->addComment("@return $className");
44
-        }
45
-        return false;
46
-    }
40
+			$method->addBody($body);
41
+			$method->addComment($section['description']);
42
+			$method->addComment('');
43
+			$method->addComment("@return $className");
44
+		}
45
+		return false;
46
+	}
47 47
 }
48 48
\ No newline at end of file
Please login to merge, or discard this patch.
codegen/ResponseAbstract.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -6,74 +6,74 @@
 block discarded – undo
6 6
 
7 7
 class ResponseAbstract extends ClassGenerator
8 8
 {
9
-    public $properties = [];
9
+	public $properties = [];
10 10
 
11
-    protected function formExtends()
12
-    {
13
-        if (strpos($this->formClassName(), 'ElementResponse')) {
14
-            return 'carono\turbotext\ArrayObject';
15
-        }
11
+	protected function formExtends()
12
+	{
13
+		if (strpos($this->formClassName(), 'ElementResponse')) {
14
+			return 'carono\turbotext\ArrayObject';
15
+		}
16 16
 
17
-        return 'carono\turbotext\ResponseAbstract';
18
-    }
17
+		return 'carono\turbotext\ResponseAbstract';
18
+	}
19 19
 
20
-    protected function formClassName()
21
-    {
22
-        $name = $this->params['name'];
23
-        $name = formClassName($name);
24
-        if (!isset($this->params['result']) && substr($name, -1, 1) == 's') {
25
-            $name = substr($name, 0, -1) . 'Element';
26
-        }
27
-        return $name . 'Response';
28
-    }
20
+	protected function formClassName()
21
+	{
22
+		$name = $this->params['name'];
23
+		$name = formClassName($name);
24
+		if (!isset($this->params['result']) && substr($name, -1, 1) == 's') {
25
+			$name = substr($name, 0, -1) . 'Element';
26
+		}
27
+		return $name . 'Response';
28
+	}
29 29
 
30
-    protected function formClassNamespace()
31
-    {
32
-        return 'carono\turbotext\response';
33
-    }
30
+	protected function formClassNamespace()
31
+	{
32
+		return 'carono\turbotext\response';
33
+	}
34 34
 
35
-    protected function formOutputPath()
36
-    {
37
-        return dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'response' . DIRECTORY_SEPARATOR . $this->formClassName() . '.php';
38
-    }
35
+	protected function formOutputPath()
36
+	{
37
+		return dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'response' . DIRECTORY_SEPARATOR . $this->formClassName() . '.php';
38
+	}
39 39
 
40
-    protected function classProperties()
41
-    {
42
-        $properties = [];
43
-        if (isset($this->params['result'])) {
44
-            $properties = [
45
-                '_responseClasses' => [
46
-                    'value' => [],
47
-                    'visibility' => 'protected'
48
-                ]
49
-            ];
50
-            $element = new self();
51
-            $params = $this->params['result'];
52
-            $params['name'] = $this->params['name'];
53
-            $element->renderToFile($params);
54
-            $varClass = $element->formClassName();
55
-            $properties['_responseClasses']['value'][$this->params['name']] = 'carono\turbotext\response\\' . $varClass;
56
-            $properties[$this->params['name']] = [
57
-                'value' => [],
58
-                'comment' => [
59
-                    stripAndWordWrap($this->params['description']),
60
-                    "@var {$varClass}[]"
61
-                ]
62
-            ];
63
-        } else {
64
-            foreach ($this->params as $param) {
65
-                if (is_string($param)) {
66
-                    continue;
67
-                }
68
-                $properties[$param['name']] = [
69
-                    'comment' => [
70
-                        stripAndWordWrap($param['description']),
71
-                        '@var ' . formParamType($param['type'])
72
-                    ]
73
-                ];
74
-            }
75
-        }
76
-        return $properties;
77
-    }
40
+	protected function classProperties()
41
+	{
42
+		$properties = [];
43
+		if (isset($this->params['result'])) {
44
+			$properties = [
45
+				'_responseClasses' => [
46
+					'value' => [],
47
+					'visibility' => 'protected'
48
+				]
49
+			];
50
+			$element = new self();
51
+			$params = $this->params['result'];
52
+			$params['name'] = $this->params['name'];
53
+			$element->renderToFile($params);
54
+			$varClass = $element->formClassName();
55
+			$properties['_responseClasses']['value'][$this->params['name']] = 'carono\turbotext\response\\' . $varClass;
56
+			$properties[$this->params['name']] = [
57
+				'value' => [],
58
+				'comment' => [
59
+					stripAndWordWrap($this->params['description']),
60
+					"@var {$varClass}[]"
61
+				]
62
+			];
63
+		} else {
64
+			foreach ($this->params as $param) {
65
+				if (is_string($param)) {
66
+					continue;
67
+				}
68
+				$properties[$param['name']] = [
69
+					'comment' => [
70
+						stripAndWordWrap($param['description']),
71
+						'@var ' . formParamType($param['type'])
72
+					]
73
+				];
74
+			}
75
+		}
76
+		return $properties;
77
+	}
78 78
 
79 79
 }
80 80
\ No newline at end of file
Please login to merge, or discard this patch.
codegen/generate.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -15,45 +15,45 @@
 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 = parseParamsFromQuery($tr->find('td')->eq(2)->find('li'));
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 = parseParamsFromQuery($tr->find('td')->eq(2)->find('li'));
46 46
 
47
-        $returns = parseReturns($uls = $tr->find('td')->eq(3)->htmlOuter());
48
-        $method = [
49
-            'name' => $name,
50
-            'description' => $tr->find('td')->eq(1)->text(),
51
-            'params' => $params,
52
-            'returns' => $returns
53
-        ];
54
-        $item['methods'][] = $method;
55
-    }
56
-    $data[] = $item;
47
+		$returns = parseReturns($uls = $tr->find('td')->eq(3)->htmlOuter());
48
+		$method = [
49
+			'name' => $name,
50
+			'description' => $tr->find('td')->eq(1)->text(),
51
+			'params' => $params,
52
+			'returns' => $returns
53
+		];
54
+		$item['methods'][] = $method;
55
+	}
56
+	$data[] = $item;
57 57
 }
58 58
 file_put_contents('data.json', json_encode($data));
59 59
 $abstractClient = new ClientAbstract();
Please login to merge, or discard this patch.
codegen/func.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -2,135 +2,135 @@
 block discarded – undo
2 2
 
3 3
 function parseParamsFromQuery($query)
4 4
 {
5
-    $params = [];
6
-    foreach ($query as $param) {
7
-        if ($parsedParam = parseParams(pq($param)->text())) {
8
-            $params[] = $parsedParam;
9
-        }
10
-    }
11
-    return $params;
5
+	$params = [];
6
+	foreach ($query as $param) {
7
+		if ($parsedParam = parseParams(pq($param)->text())) {
8
+			$params[] = $parsedParam;
9
+		}
10
+	}
11
+	return $params;
12 12
 }
13 13
 
14 14
 function clearFolder($folder)
15 15
 {
16
-    $files = glob(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . '*');
17
-    foreach ($files as $file) {
18
-        if (is_file($file)) {
19
-            @unlink($file);
20
-        }
21
-    }
16
+	$files = glob(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . '*');
17
+	foreach ($files as $file) {
18
+		if (is_file($file)) {
19
+			@unlink($file);
20
+		}
21
+	}
22 22
 }
23 23
 
24 24
 function stripAndWordWrap($str)
25 25
 {
26
-    return wordwrap(stripSpaces($str), 180) . "\n";
26
+	return wordwrap(stripSpaces($str), 180) . "\n";
27 27
 }
28 28
 
29 29
 function formParamLine($param)
30 30
 {
31
-    return '**' . $param['name'] . "** ({$param['type']}) - " . stripLines($param['description']);
31
+	return '**' . $param['name'] . "** ({$param['type']}) - " . stripLines($param['description']);
32 32
 }
33 33
 
34 34
 function stripSpaces($str)
35 35
 {
36
-    $str = preg_replace('/[\s]{2,}/', " ", $str);
37
-    return $str;
36
+	$str = preg_replace('/[\s]{2,}/', " ", $str);
37
+	return $str;
38 38
 }
39 39
 
40 40
 function stripLines($str)
41 41
 {
42
-    $str = str_replace("\n", " ", $str);
43
-    $str = stripSpaces($str);
44
-    return $str;
42
+	$str = str_replace("\n", " ", $str);
43
+	$str = stripSpaces($str);
44
+	return $str;
45 45
 }
46 46
 
47 47
 function formMethodName($str)
48 48
 {
49
-    $arr = array_filter(explode('_', $str));
50
-    $arr = array_map('ucfirst', $arr);
51
-    $arr[0] = lcfirst($arr[0]);
52
-    return join('', $arr);
49
+	$arr = array_filter(explode('_', $str));
50
+	$arr = array_map('ucfirst', $arr);
51
+	$arr[0] = lcfirst($arr[0]);
52
+	return join('', $arr);
53 53
 }
54 54
 
55 55
 function formClassName($str, $clear = ['get_', '_array'])
56 56
 {
57
-    foreach ($clear as $item) {
58
-        $str = str_ireplace($item, '', $str);
59
-    }
60
-    $arr = array_filter(explode('_', $str));
61
-    $arr = array_map('ucfirst', $arr);
62
-    return join('', $arr);
57
+	foreach ($clear as $item) {
58
+		$str = str_ireplace($item, '', $str);
59
+	}
60
+	$arr = array_filter(explode('_', $str));
61
+	$arr = array_map('ucfirst', $arr);
62
+	return join('', $arr);
63 63
 }
64 64
 
65 65
 function formParamType($str)
66 66
 {
67
-    switch ($str) {
68
-        case 'text':
69
-            return 'string';
70
-            break;
71
-        case 'date':
72
-            return 'string Y-m-d';
73
-            break;
74
-        case 'datetime':
75
-            return 'string Y-m-d H:i:s';
76
-            break;
77
-    }
78
-    return $str;
67
+	switch ($str) {
68
+		case 'text':
69
+			return 'string';
70
+			break;
71
+		case 'date':
72
+			return 'string Y-m-d';
73
+			break;
74
+		case 'datetime':
75
+			return 'string Y-m-d H:i:s';
76
+			break;
77
+	}
78
+	return $str;
79 79
 }
80 80
 
81 81
 function parseParams($str)
82 82
 {
83 83
 
84
-    $str = trim($str, " \t\n\r\0\x0B");
85
-    if (preg_match('/^(\w+)\s?(\*?)\s+\((\w+)\)\s+-\s+(.+)/uis', $str, $m)) {
86
-        return [
87
-            'name' => $m[1],
88
-            'type' => $m[3],
89
-            'description' => $m[4],
90
-            'required' => $m[2] ? true : (mb_strpos($m[4], 'Необязательный', 0, 'utf-8') === false)
91
-        ];
92
-    }
93
-
94
-    return [];
84
+	$str = trim($str, " \t\n\r\0\x0B");
85
+	if (preg_match('/^(\w+)\s?(\*?)\s+\((\w+)\)\s+-\s+(.+)/uis', $str, $m)) {
86
+		return [
87
+			'name' => $m[1],
88
+			'type' => $m[3],
89
+			'description' => $m[4],
90
+			'required' => $m[2] ? true : (mb_strpos($m[4], 'Необязательный', 0, 'utf-8') === false)
91
+		];
92
+	}
93
+
94
+	return [];
95 95
 }
96 96
 
97 97
 function parseReturns($tdHtml)
98 98
 {
99
-    $uls = pq($tdHtml)->find('ul');
100
-    if ($uls->count() == 1 && strpos($tdHtml, 'Каждый элемент') !== false) {
101
-        if (preg_match('/<td>(.)+<ul>/s', $tdHtml, $m)) {
102
-            $ul = "<ul><li>" . trim(strip_tags($m[0])) . "</li></ul>";
103
-            $uls = pq("<td>$ul{$uls->eq(0)->htmlOuter()}</td>")->find('ul');
104
-        }
105
-    }
106
-    $count = $uls->count();
107
-    $parsing = parseParamsFromQuery($uls->eq($count == 2 ? 1 : 0)->find('li'));
108
-    if ($count == 2) {
109
-        $returnParam = parseParams($uls->eq(0)->text());
110
-        $returnParam['result'] = $parsing;
111
-        return [$returnParam];
112
-    }
113
-
114
-    return $parsing;
99
+	$uls = pq($tdHtml)->find('ul');
100
+	if ($uls->count() == 1 && strpos($tdHtml, 'Каждый элемент') !== false) {
101
+		if (preg_match('/<td>(.)+<ul>/s', $tdHtml, $m)) {
102
+			$ul = "<ul><li>" . trim(strip_tags($m[0])) . "</li></ul>";
103
+			$uls = pq("<td>$ul{$uls->eq(0)->htmlOuter()}</td>")->find('ul');
104
+		}
105
+	}
106
+	$count = $uls->count();
107
+	$parsing = parseParamsFromQuery($uls->eq($count == 2 ? 1 : 0)->find('li'));
108
+	if ($count == 2) {
109
+		$returnParam = parseParams($uls->eq(0)->text());
110
+		$returnParam['result'] = $parsing;
111
+		return [$returnParam];
112
+	}
113
+
114
+	return $parsing;
115 115
 }
116 116
 
117 117
 function asTable($array)
118 118
 {
119
-    $header = array_shift($array);
120
-    $content = "\n\n|" . join("|", $header) . "\n";
121
-    $content .= preg_replace('/[^\|]/iu', '-', trim($content)) . "\n";
122
-    foreach ($array as $key => $columns) {
123
-        $content .= "|" . join("|", $columns) . "\n";
124
-    }
125
-    return $content;
119
+	$header = array_shift($array);
120
+	$content = "\n\n|" . join("|", $header) . "\n";
121
+	$content .= preg_replace('/[^\|]/iu', '-', trim($content)) . "\n";
122
+	foreach ($array as $key => $columns) {
123
+		$content .= "|" . join("|", $columns) . "\n";
124
+	}
125
+	return $content;
126 126
 }
127 127
 
128 128
 function asHeader($string)
129 129
 {
130
-    return "\n\n" . $string . "\n" . str_repeat('=', mb_strlen($string, 'utf-8')) . "\n";
130
+	return "\n\n" . $string . "\n" . str_repeat('=', mb_strlen($string, 'utf-8')) . "\n";
131 131
 }
132 132
 
133 133
 function asCode($code)
134 134
 {
135
-    return "`$code`";
135
+	return "`$code`";
136 136
 }
137 137
\ No newline at end of file
Please login to merge, or discard this patch.