@@ -6,22 +6,22 @@  | 
                                                    ||
| 6 | 6 | |
| 7 | 7 | abstract class ResponseAbstract extends ArrayObject  | 
                                                        
| 8 | 8 |  { | 
                                                        
| 9 | - /**  | 
                                                        |
| 10 | - * @var boolean  | 
                                                        |
| 11 | - */  | 
                                                        |
| 12 | - public $success;  | 
                                                        |
| 13 | - /**  | 
                                                        |
| 14 | - * @var string  | 
                                                        |
| 15 | - */  | 
                                                        |
| 16 | - public $errors;  | 
                                                        |
| 9 | + /**  | 
                                                        |
| 10 | + * @var boolean  | 
                                                        |
| 11 | + */  | 
                                                        |
| 12 | + public $success;  | 
                                                        |
| 13 | + /**  | 
                                                        |
| 14 | + * @var string  | 
                                                        |
| 15 | + */  | 
                                                        |
| 16 | + public $errors;  | 
                                                        |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - /**  | 
                                                        |
| 20 | - * @param $property  | 
                                                        |
| 21 | - * @return mixed|null  | 
                                                        |
| 22 | - */  | 
                                                        |
| 23 | - public function getResponseClass($property)  | 
                                                        |
| 24 | -    { | 
                                                        |
| 25 | - return isset($this->_responseClasses[$property]) ? $this->_responseClasses[$property] : null;  | 
                                                        |
| 26 | - }  | 
                                                        |
| 19 | + /**  | 
                                                        |
| 20 | + * @param $property  | 
                                                        |
| 21 | + * @return mixed|null  | 
                                                        |
| 22 | + */  | 
                                                        |
| 23 | + public function getResponseClass($property)  | 
                                                        |
| 24 | +	{ | 
                                                        |
| 25 | + return isset($this->_responseClasses[$property]) ? $this->_responseClasses[$property] : null;  | 
                                                        |
| 26 | + }  | 
                                                        |
| 27 | 27 | }  | 
                                                        
| 28 | 28 | \ No newline at end of file  | 
                                                        
@@ -6,23 +6,23 @@  | 
                                                    ||
| 6 | 6 | |
| 7 | 7 | abstract class RequestAbstract  | 
                                                        
| 8 | 8 |  { | 
                                                        
| 9 | - protected $_client;  | 
                                                        |
| 9 | + protected $_client;  | 
                                                        |
| 10 | 10 | |
| 11 | - /**  | 
                                                        |
| 12 | - * RequestAbstract constructor.  | 
                                                        |
| 13 | - *  | 
                                                        |
| 14 | - * @param Client|ClientAbstract $client  | 
                                                        |
| 15 | - */  | 
                                                        |
| 16 | - public function __construct($client)  | 
                                                        |
| 17 | -    { | 
                                                        |
| 18 | - $this->_client = $client;  | 
                                                        |
| 19 | - }  | 
                                                        |
| 11 | + /**  | 
                                                        |
| 12 | + * RequestAbstract constructor.  | 
                                                        |
| 13 | + *  | 
                                                        |
| 14 | + * @param Client|ClientAbstract $client  | 
                                                        |
| 15 | + */  | 
                                                        |
| 16 | + public function __construct($client)  | 
                                                        |
| 17 | +	{ | 
                                                        |
| 18 | + $this->_client = $client;  | 
                                                        |
| 19 | + }  | 
                                                        |
| 20 | 20 | |
| 21 | - /**  | 
                                                        |
| 22 | - * @return Client  | 
                                                        |
| 23 | - */  | 
                                                        |
| 24 | - public function getClient()  | 
                                                        |
| 25 | -    { | 
                                                        |
| 26 | - return $this->_client;  | 
                                                        |
| 27 | - }  | 
                                                        |
| 21 | + /**  | 
                                                        |
| 22 | + * @return Client  | 
                                                        |
| 23 | + */  | 
                                                        |
| 24 | + public function getClient()  | 
                                                        |
| 25 | +	{ | 
                                                        |
| 26 | + return $this->_client;  | 
                                                        |
| 27 | + }  | 
                                                        |
| 28 | 28 | }  | 
                                                        
| 29 | 29 | \ No newline at end of file  | 
                                                        
@@ -6,25 +6,25 @@  | 
                                                    ||
| 6 | 6 | |
| 7 | 7 | class ArrayObject extends \ArrayObject  | 
                                                        
| 8 | 8 |  { | 
                                                        
| 9 | - /**  | 
                                                        |
| 10 | - * ResponseAbstract constructor.  | 
                                                        |
| 11 | - *  | 
                                                        |
| 12 | - * @param array $input  | 
                                                        |
| 13 | - */  | 
                                                        |
| 14 | - public function __construct($input = [])  | 
                                                        |
| 15 | -    { | 
                                                        |
| 16 | - parent::__construct($input, self::ARRAY_AS_PROPS, "ArrayIterator");  | 
                                                        |
| 17 | - }  | 
                                                        |
| 9 | + /**  | 
                                                        |
| 10 | + * ResponseAbstract constructor.  | 
                                                        |
| 11 | + *  | 
                                                        |
| 12 | + * @param array $input  | 
                                                        |
| 13 | + */  | 
                                                        |
| 14 | + public function __construct($input = [])  | 
                                                        |
| 15 | +	{ | 
                                                        |
| 16 | + parent::__construct($input, self::ARRAY_AS_PROPS, "ArrayIterator");  | 
                                                        |
| 17 | + }  | 
                                                        |
| 18 | 18 | |
| 19 | - public function toArray()  | 
                                                        |
| 20 | -    { | 
                                                        |
| 21 | - $result = [];  | 
                                                        |
| 22 | -        foreach ($this as $key => $value) { | 
                                                        |
| 23 | - $result[$key] = $value;  | 
                                                        |
| 24 | - }  | 
                                                        |
| 25 | -        foreach ((new \ReflectionClass($this))->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { | 
                                                        |
| 26 | -            $result[$property->name] = $this->{$property->name}; | 
                                                        |
| 27 | - }  | 
                                                        |
| 28 | - return $result;  | 
                                                        |
| 29 | - }  | 
                                                        |
| 19 | + public function toArray()  | 
                                                        |
| 20 | +	{ | 
                                                        |
| 21 | + $result = [];  | 
                                                        |
| 22 | +		foreach ($this as $key => $value) { | 
                                                        |
| 23 | + $result[$key] = $value;  | 
                                                        |
| 24 | + }  | 
                                                        |
| 25 | +		foreach ((new \ReflectionClass($this))->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { | 
                                                        |
| 26 | +			$result[$property->name] = $this->{$property->name}; | 
                                                        |
| 27 | + }  | 
                                                        |
| 28 | + return $result;  | 
                                                        |
| 29 | + }  | 
                                                        |
| 30 | 30 | }  | 
                                                        
| 31 | 31 | \ No newline at end of file  | 
                                                        
@@ -6,42 +6,42 @@  | 
                                                    ||
| 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  | 
                                                        
@@ -46,55 +46,55 @@  | 
                                                    ||
| 46 | 46 | HTML;  | 
                                                        
| 47 | 47 | |
| 48 | 48 | $description = [  | 
                                                        
| 49 | - ['Метод', 'Описание']  | 
                                                        |
| 49 | + ['Метод', 'Описание']  | 
                                                        |
| 50 | 50 | ];  | 
                                                        
| 51 | 51 | $sectionData = [];  | 
                                                        
| 52 | 52 |  foreach ($data as $section) { | 
                                                        
| 53 | - $description[] = [  | 
                                                        |
| 54 | - '$client->' . $section['name'] . '()',  | 
                                                        |
| 55 | - $section['description']  | 
                                                        |
| 56 | - ];  | 
                                                        |
| 57 | - $sectionData[] = asHeader($section['description']);  | 
                                                        |
| 58 | - $sectionData[] = <<<HTML  | 
                                                        |
| 53 | + $description[] = [  | 
                                                        |
| 54 | + '$client->' . $section['name'] . '()',  | 
                                                        |
| 55 | + $section['description']  | 
                                                        |
| 56 | + ];  | 
                                                        |
| 57 | + $sectionData[] = asHeader($section['description']);  | 
                                                        |
| 58 | + $sectionData[] = <<<HTML  | 
                                                        |
| 59 | 59 | ```php  | 
                                                        
| 60 | 60 |  \$client->{$section['name']}(); | 
                                                        
| 61 | 61 | ```  | 
                                                        
| 62 | 62 | HTML;  | 
                                                        
| 63 | 63 | |
| 64 | - $methods = [  | 
                                                        |
| 65 | - ['Метод', 'Описание', 'Входные данные', 'Выходные данные']  | 
                                                        |
| 66 | - ];  | 
                                                        |
| 64 | + $methods = [  | 
                                                        |
| 65 | + ['Метод', 'Описание', 'Входные данные', 'Выходные данные']  | 
                                                        |
| 66 | + ];  | 
                                                        |
| 67 | 67 | |
| 68 | -    foreach ($section['methods'] as $method) { | 
                                                        |
| 69 | - $results = [];  | 
                                                        |
| 70 | - $params = [];  | 
                                                        |
| 71 | -        foreach ($method['returns'] as $result) { | 
                                                        |
| 72 | - $results[] = formParamLine($result);  | 
                                                        |
| 73 | -            if (isset($result['result'])) { | 
                                                        |
| 74 | -                foreach ($result['result'] as $res) { | 
                                                        |
| 75 | - $results[] = formParamLine($res);  | 
                                                        |
| 76 | - }  | 
                                                        |
| 77 | - }  | 
                                                        |
| 78 | - }  | 
                                                        |
| 79 | -        if (isset($method['params'])) { | 
                                                        |
| 80 | -            foreach ($method['params'] as $param) { | 
                                                        |
| 81 | -                $params[] = '**' . $param['name'] . "** ({$param['type']}) - " . stripLines($param['description']); | 
                                                        |
| 82 | - }  | 
                                                        |
| 83 | - }  | 
                                                        |
| 68 | +	foreach ($section['methods'] as $method) { | 
                                                        |
| 69 | + $results = [];  | 
                                                        |
| 70 | + $params = [];  | 
                                                        |
| 71 | +		foreach ($method['returns'] as $result) { | 
                                                        |
| 72 | + $results[] = formParamLine($result);  | 
                                                        |
| 73 | +			if (isset($result['result'])) { | 
                                                        |
| 74 | +				foreach ($result['result'] as $res) { | 
                                                        |
| 75 | + $results[] = formParamLine($res);  | 
                                                        |
| 76 | + }  | 
                                                        |
| 77 | + }  | 
                                                        |
| 78 | + }  | 
                                                        |
| 79 | +		if (isset($method['params'])) { | 
                                                        |
| 80 | +			foreach ($method['params'] as $param) { | 
                                                        |
| 81 | +				$params[] = '**' . $param['name'] . "** ({$param['type']}) - " . stripLines($param['description']); | 
                                                        |
| 82 | + }  | 
                                                        |
| 83 | + }  | 
                                                        |
| 84 | 84 | |
| 85 | - $methods[] = [  | 
                                                        |
| 86 | - formMethodName($method['name']),  | 
                                                        |
| 87 | - stripLines($method['description']),  | 
                                                        |
| 88 | -            join('<br /><br />', $params), | 
                                                        |
| 89 | -            join('<br /><br />', $results), | 
                                                        |
| 90 | - ];  | 
                                                        |
| 91 | - }  | 
                                                        |
| 92 | - $sectionData[] = asTable($methods);  | 
                                                        |
| 85 | + $methods[] = [  | 
                                                        |
| 86 | + formMethodName($method['name']),  | 
                                                        |
| 87 | + stripLines($method['description']),  | 
                                                        |
| 88 | +			join('<br /><br />', $params), | 
                                                        |
| 89 | +			join('<br /><br />', $results), | 
                                                        |
| 90 | + ];  | 
                                                        |
| 91 | + }  | 
                                                        |
| 92 | + $sectionData[] = asTable($methods);  | 
                                                        |
| 93 | 93 | }  | 
                                                        
| 94 | 94 | $content .= asTable($description);  | 
                                                        
| 95 | 95 | |
| 96 | 96 |  foreach ($sectionData as $sectionDatum) { | 
                                                        
| 97 | - $content .= $sectionDatum;  | 
                                                        |
| 97 | + $content .= $sectionDatum;  | 
                                                        |
| 98 | 98 | }  | 
                                                        
| 99 | 99 | |
| 100 | 100 |  $content .= asHeader('Внимание'); | 
                                                        
@@ -6,74 +6,74 @@  | 
                                                    ||
| 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 | -        } else { | 
                                                        |
| 16 | - return 'carono\turbotext\ResponseAbstract';  | 
                                                        |
| 17 | - }  | 
                                                        |
| 18 | - }  | 
                                                        |
| 11 | + protected function formExtends()  | 
                                                        |
| 12 | +	{ | 
                                                        |
| 13 | +		if (strpos($this->formClassName(), 'ElementResponse')) { | 
                                                        |
| 14 | + return 'carono\turbotext\ArrayObject';  | 
                                                        |
| 15 | +		} else { | 
                                                        |
| 16 | + return 'carono\turbotext\ResponseAbstract';  | 
                                                        |
| 17 | + }  | 
                                                        |
| 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  | 
                                                        
@@ -6,109 +6,109 @@  | 
                                                    ||
| 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 | - $response->renderToFile($methodData['returns'][0]);  | 
                                                        |
| 85 | - $className = $response->formClassNamespace() . '\\' . $response->formClassName();  | 
                                                        |
| 86 | -            } elseif ($methodData['returns']) { | 
                                                        |
| 87 | - $methodData['returns']['name'] = $methodData['name'];  | 
                                                        |
| 88 | - $response->properties['asd'] = 213;  | 
                                                        |
| 89 | - $response->renderToFile($methodData['returns']);  | 
                                                        |
| 90 | - $className = $response->formClassNamespace() . '\\' . $response->formClassName();  | 
                                                        |
| 91 | -            } else { | 
                                                        |
| 92 | - $className = 'carono\turbotext\Response';  | 
                                                        |
| 93 | - }  | 
                                                        |
| 94 | -            $method->addComment("@return \\$className|string|\stdClass|\SimpleXMLElement"); | 
                                                        |
| 95 | -            $method->addBody("return \$this->getClient()->getContent('api', \$params, '$className');"); | 
                                                        |
| 96 | - }  | 
                                                        |
| 97 | - return false;  | 
                                                        |
| 98 | - }  | 
                                                        |
| 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 | + $response->renderToFile($methodData['returns'][0]);  | 
                                                        |
| 85 | + $className = $response->formClassNamespace() . '\\' . $response->formClassName();  | 
                                                        |
| 86 | +			} elseif ($methodData['returns']) { | 
                                                        |
| 87 | + $methodData['returns']['name'] = $methodData['name'];  | 
                                                        |
| 88 | + $response->properties['asd'] = 213;  | 
                                                        |
| 89 | + $response->renderToFile($methodData['returns']);  | 
                                                        |
| 90 | + $className = $response->formClassNamespace() . '\\' . $response->formClassName();  | 
                                                        |
| 91 | +			} else { | 
                                                        |
| 92 | + $className = 'carono\turbotext\Response';  | 
                                                        |
| 93 | + }  | 
                                                        |
| 94 | +			$method->addComment("@return \\$className|string|\stdClass|\SimpleXMLElement"); | 
                                                        |
| 95 | +			$method->addBody("return \$this->getClient()->getContent('api', \$params, '$className');"); | 
                                                        |
| 96 | + }  | 
                                                        |
| 97 | + return false;  | 
                                                        |
| 98 | + }  | 
                                                        |
| 99 | 99 | |
| 100 | - protected static function arrayAsPhpVar($array)  | 
                                                        |
| 101 | -    { | 
                                                        |
| 102 | - $export = [];  | 
                                                        |
| 103 | -        foreach ($array as $key => $value) { | 
                                                        |
| 104 | - $export[] = "'$key' => " . (strpos($value, '$') === false ? "'$value'" : $value);  | 
                                                        |
| 105 | - }  | 
                                                        |
| 106 | -        $export = join(",\n\t", $export); | 
                                                        |
| 107 | -        if ($array) { | 
                                                        |
| 108 | - $result = "[\n\t$export\n]";  | 
                                                        |
| 109 | -        } else { | 
                                                        |
| 110 | - $result = "[]";  | 
                                                        |
| 111 | - }  | 
                                                        |
| 112 | - return $result;  | 
                                                        |
| 113 | - }  | 
                                                        |
| 100 | + protected static function arrayAsPhpVar($array)  | 
                                                        |
| 101 | +	{ | 
                                                        |
| 102 | + $export = [];  | 
                                                        |
| 103 | +		foreach ($array as $key => $value) { | 
                                                        |
| 104 | + $export[] = "'$key' => " . (strpos($value, '$') === false ? "'$value'" : $value);  | 
                                                        |
| 105 | + }  | 
                                                        |
| 106 | +		$export = join(",\n\t", $export); | 
                                                        |
| 107 | +		if ($array) { | 
                                                        |
| 108 | + $result = "[\n\t$export\n]";  | 
                                                        |
| 109 | +		} else { | 
                                                        |
| 110 | + $result = "[]";  | 
                                                        |
| 111 | + }  | 
                                                        |
| 112 | + return $result;  | 
                                                        |
| 113 | + }  | 
                                                        |
| 114 | 114 | }  | 
                                                        
| 115 | 115 | \ No newline at end of file  | 
                                                        
@@ -80,7 +80,7 @@  | 
                                                    ||
| 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 | }  | 
                                                        
@@ -66,7 +66,7 @@  | 
                                                    ||
| 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 | }  |