@@ -12,32 +12,32 @@ discard block |
||
| 12 | 12 | { |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * @var string $ident |
|
| 16 | - */ |
|
| 15 | + * @var string $ident |
|
| 16 | + */ |
|
| 17 | 17 | private $ident; |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | - * The HTTP methods to wthich this route resolve to. |
|
| 21 | - * Ex: ['GET', 'POST', 'PUT', 'DELETE'] |
|
| 22 | - * @var array $methods |
|
| 23 | - */ |
|
| 20 | + * The HTTP methods to wthich this route resolve to. |
|
| 21 | + * Ex: ['GET', 'POST', 'PUT', 'DELETE'] |
|
| 22 | + * @var array $methods |
|
| 23 | + */ |
|
| 24 | 24 | private $methods = ['GET']; |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * The identifier of the controller class. |
|
| 28 | - * @var string $controller |
|
| 29 | - */ |
|
| 27 | + * The identifier of the controller class. |
|
| 28 | + * @var string $controller |
|
| 29 | + */ |
|
| 30 | 30 | private $controller; |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | - * @var string $group |
|
| 34 | - */ |
|
| 33 | + * @var string $group |
|
| 34 | + */ |
|
| 35 | 35 | private $group; |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | - * @param string $ident |
|
| 39 | - * @return AbstractRouteConfig Chainable |
|
| 40 | - */ |
|
| 38 | + * @param string $ident |
|
| 39 | + * @return AbstractRouteConfig Chainable |
|
| 40 | + */ |
|
| 41 | 41 | public function set_ident($ident) |
| 42 | 42 | { |
| 43 | 43 | $this->ident = $ident; |
@@ -45,17 +45,17 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | - * @return string |
|
| 49 | - */ |
|
| 48 | + * @return string |
|
| 49 | + */ |
|
| 50 | 50 | public function ident() |
| 51 | 51 | { |
| 52 | 52 | return $this->ident; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | - * @param string $controller |
|
| 57 | - * @return AbstractRouteConfig Chainable |
|
| 58 | - */ |
|
| 56 | + * @param string $controller |
|
| 57 | + * @return AbstractRouteConfig Chainable |
|
| 58 | + */ |
|
| 59 | 59 | public function set_controller($controller) |
| 60 | 60 | { |
| 61 | 61 | $this->controller = $controller; |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | - * @return string |
|
| 67 | - */ |
|
| 66 | + * @return string |
|
| 67 | + */ |
|
| 68 | 68 | public function controller() |
| 69 | 69 | { |
| 70 | 70 | if ($this->controller === null) { |
@@ -74,17 +74,17 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | - * @return string |
|
| 78 | - */ |
|
| 77 | + * @return string |
|
| 78 | + */ |
|
| 79 | 79 | public function default_controller() |
| 80 | 80 | { |
| 81 | 81 | return $this->ident(); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | - * @param array $methods |
|
| 86 | - * @return AbstractRouteConfig Chainable |
|
| 87 | - */ |
|
| 85 | + * @param array $methods |
|
| 86 | + * @return AbstractRouteConfig Chainable |
|
| 87 | + */ |
|
| 88 | 88 | public function set_methods(array $methods) |
| 89 | 89 | { |
| 90 | 90 | $this->methods = $methods; |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | - * @return array |
|
| 96 | - */ |
|
| 95 | + * @return array |
|
| 96 | + */ |
|
| 97 | 97 | public function methods() |
| 98 | 98 | { |
| 99 | 99 | return $this->methods; |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | interface RouteInterface |
| 13 | 13 | { |
| 14 | 14 | /** |
| 15 | - * |
|
| 16 | - */ |
|
| 15 | + * |
|
| 16 | + */ |
|
| 17 | 17 | public function __invoke(RequestInterface $request, ResponseInterface $response); |
| 18 | 18 | } |
@@ -49,15 +49,15 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | $routes = $this->config(); |
| 51 | 51 | |
| 52 | - $templates = ( isset($routes['templates']) ? $routes['templates'] : [] ); |
|
| 52 | + $templates = (isset($routes['templates']) ? $routes['templates'] : []); |
|
| 53 | 53 | $this->logger()->debug('Templates', (array)$templates); |
| 54 | 54 | foreach ($templates as $template_ident => $template_config) { |
| 55 | - $methods = ( isset($tempate_config['methods']) ? $template_config['methods'] : [ 'GET' ] ); |
|
| 55 | + $methods = (isset($tempate_config['methods']) ? $template_config['methods'] : ['GET']); |
|
| 56 | 56 | |
| 57 | 57 | $route = $this->app()->map( |
| 58 | 58 | $methods, |
| 59 | 59 | $template_ident, |
| 60 | - function ( |
|
| 60 | + function( |
|
| 61 | 61 | RequestInterface $request, |
| 62 | 62 | ResponseInterface $response, |
| 63 | 63 | $args |
@@ -92,15 +92,15 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | $routes = $this->config(); |
| 94 | 94 | |
| 95 | - $actions = ( isset($routes['actions']) ? $routes['actions'] : [] ); |
|
| 95 | + $actions = (isset($routes['actions']) ? $routes['actions'] : []); |
|
| 96 | 96 | $this->logger()->debug('Actions', (array)$actions); |
| 97 | 97 | foreach ($actions as $action_ident => $action_config) { |
| 98 | - $methods = ( isset($action_config['methods']) ? $action_config['methods'] : [ 'POST' ] ); |
|
| 98 | + $methods = (isset($action_config['methods']) ? $action_config['methods'] : ['POST']); |
|
| 99 | 99 | |
| 100 | 100 | $route = $this->app()->map( |
| 101 | 101 | $methods, |
| 102 | 102 | $action_ident, |
| 103 | - function ( |
|
| 103 | + function( |
|
| 104 | 104 | RequestInterface $request, |
| 105 | 105 | ResponseInterface $response, |
| 106 | 106 | $args |
@@ -134,15 +134,15 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | $routes = $this->config(); |
| 136 | 136 | |
| 137 | - $scripts = ( isset($routes['scripts']) ? $routes['scripts'] : [] ); |
|
| 137 | + $scripts = (isset($routes['scripts']) ? $routes['scripts'] : []); |
|
| 138 | 138 | $this->logger()->debug('Scripts', (array)$scripts); |
| 139 | 139 | foreach ($scripts as $script_ident => $script_config) { |
| 140 | - $methods = ( isset($script_config['methods']) ? $script_config['methods'] : [ 'GET' ] ); |
|
| 140 | + $methods = (isset($script_config['methods']) ? $script_config['methods'] : ['GET']); |
|
| 141 | 141 | |
| 142 | 142 | $route = $this->app()->map( |
| 143 | 143 | $methods, |
| 144 | 144 | $script_ident, |
| 145 | - function ( |
|
| 145 | + function( |
|
| 146 | 146 | RequestInterface $request, |
| 147 | 147 | ResponseInterface $response, |
| 148 | 148 | $args |
@@ -22,15 +22,15 @@ discard block |
||
| 22 | 22 | class RouteManager extends AbstractManager |
| 23 | 23 | { |
| 24 | 24 | /** |
| 25 | - * Set up the routes |
|
| 26 | - * |
|
| 27 | - * There are 3 types of routes: |
|
| 28 | - * - `templates` |
|
| 29 | - * - `actions` |
|
| 30 | - * - `scripts |
|
| 31 | - * |
|
| 32 | - * @return void |
|
| 33 | - */ |
|
| 25 | + * Set up the routes |
|
| 26 | + * |
|
| 27 | + * There are 3 types of routes: |
|
| 28 | + * - `templates` |
|
| 29 | + * - `actions` |
|
| 30 | + * - `scripts |
|
| 31 | + * |
|
| 32 | + * @return void |
|
| 33 | + */ |
|
| 34 | 34 | public function setup_routes() |
| 35 | 35 | { |
| 36 | 36 | if (PHP_SAPI == 'cli') { |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | - * @throws Exception |
|
| 46 | - * @return void |
|
| 47 | - */ |
|
| 45 | + * @throws Exception |
|
| 46 | + * @return void |
|
| 47 | + */ |
|
| 48 | 48 | protected function setup_template_routes() |
| 49 | 49 | { |
| 50 | 50 | $routes = $this->config(); |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $route = new TemplateRoute([ |
| 77 | - 'app' => $this, |
|
| 78 | - 'config' => new TemplateRouteConfig($template_config), |
|
| 79 | - 'logger' => $this->logger |
|
| 77 | + 'app' => $this, |
|
| 78 | + 'config' => new TemplateRouteConfig($template_config), |
|
| 79 | + 'logger' => $this->logger |
|
| 80 | 80 | ]); |
| 81 | 81 | // Invoke template route |
| 82 | 82 | return $route($request, $response); |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | - * @return void |
|
| 94 | - */ |
|
| 93 | + * @return void |
|
| 94 | + */ |
|
| 95 | 95 | protected function setup_action_routes() |
| 96 | 96 | { |
| 97 | 97 | $routes = $this->config(); |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | - * @return void |
|
| 136 | - */ |
|
| 135 | + * @return void |
|
| 136 | + */ |
|
| 137 | 137 | protected function setup_script_routes() |
| 138 | 138 | { |
| 139 | 139 | $routes = $this->config(); |
@@ -30,23 +30,23 @@ discard block |
||
| 30 | 30 | use ConfigurableTrait; |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | - * @var \Slim\App $app |
|
| 34 | - */ |
|
| 33 | + * @var \Slim\App $app |
|
| 34 | + */ |
|
| 35 | 35 | private $app; |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @var LoggerInterface $logger |
| 39 | - */ |
|
| 39 | + */ |
|
| 40 | 40 | private $logger; |
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | - * Dependencies: |
|
| 45 | - * - `config` |
|
| 46 | - * - `app` |
|
| 47 | - * |
|
| 48 | - * @throws InvalidArgumentException |
|
| 49 | - */ |
|
| 44 | + * Dependencies: |
|
| 45 | + * - `config` |
|
| 46 | + * - `app` |
|
| 47 | + * |
|
| 48 | + * @throws InvalidArgumentException |
|
| 49 | + */ |
|
| 50 | 50 | public function __construct($data) |
| 51 | 51 | { |
| 52 | 52 | $this->set_config($data['config']); |
@@ -64,22 +64,22 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | - * > LoggerAwareInterface > setLogger() |
|
| 68 | - * |
|
| 69 | - * Fulfills the PSR-1 style LoggerAwareInterface |
|
| 70 | - * |
|
| 71 | - * @param LoggerInterface $logger |
|
| 72 | - * @return AbstractEngine Chainable |
|
| 73 | - */ |
|
| 67 | + * > LoggerAwareInterface > setLogger() |
|
| 68 | + * |
|
| 69 | + * Fulfills the PSR-1 style LoggerAwareInterface |
|
| 70 | + * |
|
| 71 | + * @param LoggerInterface $logger |
|
| 72 | + * @return AbstractEngine Chainable |
|
| 73 | + */ |
|
| 74 | 74 | public function setLogger(LoggerInterface $logger) |
| 75 | 75 | { |
| 76 | 76 | return $this->set_logger($logger); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | - * @param LoggerInterface $logger |
|
| 81 | - * @return AbstractEngine Chainable |
|
| 82 | - */ |
|
| 80 | + * @param LoggerInterface $logger |
|
| 81 | + * @return AbstractEngine Chainable |
|
| 82 | + */ |
|
| 83 | 83 | public function set_logger(LoggerInterface $logger = null) |
| 84 | 84 | { |
| 85 | 85 | $this->logger = $logger; |
@@ -87,24 +87,24 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | - * @erturn LoggerInterface |
|
| 91 | - */ |
|
| 90 | + * @erturn LoggerInterface |
|
| 91 | + */ |
|
| 92 | 92 | public function logger() |
| 93 | 93 | { |
| 94 | 94 | return $this->logger; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | - * ConfigurableTrait > create_config() |
|
| 99 | - */ |
|
| 98 | + * ConfigurableTrait > create_config() |
|
| 99 | + */ |
|
| 100 | 100 | public function create_config($data = null) |
| 101 | 101 | { |
| 102 | 102 | return new ScriptRouteConfig($data); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | - * @return void |
|
| 107 | - */ |
|
| 106 | + * @return void |
|
| 107 | + */ |
|
| 108 | 108 | public function __invoke(RequestInterface $request, ResponseInterface $response) |
| 109 | 109 | { |
| 110 | 110 | unset($request); |
@@ -29,23 +29,23 @@ discard block |
||
| 29 | 29 | use ConfigurableTrait; |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | - * @var \Slim\App $app |
|
| 33 | - */ |
|
| 32 | + * @var \Slim\App $app |
|
| 33 | + */ |
|
| 34 | 34 | private $app; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * @var LoggerInterface $logger |
| 38 | - */ |
|
| 38 | + */ |
|
| 39 | 39 | private $logger; |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * Dependencies: |
|
| 43 | - * - `config` |
|
| 44 | - * - `app` |
|
| 45 | - * |
|
| 46 | - * @param array $data Dependencies |
|
| 47 | - * @throws InvalidArgumentException |
|
| 48 | - */ |
|
| 42 | + * Dependencies: |
|
| 43 | + * - `config` |
|
| 44 | + * - `app` |
|
| 45 | + * |
|
| 46 | + * @param array $data Dependencies |
|
| 47 | + * @throws InvalidArgumentException |
|
| 48 | + */ |
|
| 49 | 49 | public function __construct(array $data) |
| 50 | 50 | { |
| 51 | 51 | $this->set_config($data['config']); |
@@ -63,22 +63,22 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | - * > LoggerAwareInterface > setLogger() |
|
| 67 | - * |
|
| 68 | - * Fulfills the PSR-1 style LoggerAwareInterface |
|
| 69 | - * |
|
| 70 | - * @param LoggerInterface $logger |
|
| 71 | - * @return AbstractEngine Chainable |
|
| 72 | - */ |
|
| 66 | + * > LoggerAwareInterface > setLogger() |
|
| 67 | + * |
|
| 68 | + * Fulfills the PSR-1 style LoggerAwareInterface |
|
| 69 | + * |
|
| 70 | + * @param LoggerInterface $logger |
|
| 71 | + * @return AbstractEngine Chainable |
|
| 72 | + */ |
|
| 73 | 73 | public function setLogger(LoggerInterface $logger) |
| 74 | 74 | { |
| 75 | 75 | return $this->set_logger($logger); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | - * @param LoggerInterface $logger |
|
| 80 | - * @return AbstractEngine Chainable |
|
| 81 | - */ |
|
| 79 | + * @param LoggerInterface $logger |
|
| 80 | + * @return AbstractEngine Chainable |
|
| 81 | + */ |
|
| 82 | 82 | public function set_logger(LoggerInterface $logger = null) |
| 83 | 83 | { |
| 84 | 84 | $this->logger = $logger; |
@@ -86,24 +86,24 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | - * @erturn LoggerInterface |
|
| 90 | - */ |
|
| 89 | + * @erturn LoggerInterface |
|
| 90 | + */ |
|
| 91 | 91 | public function logger() |
| 92 | 92 | { |
| 93 | 93 | return $this->logger; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | - * ConfigurableTrait > create_config() |
|
| 98 | - */ |
|
| 97 | + * ConfigurableTrait > create_config() |
|
| 98 | + */ |
|
| 99 | 99 | public function create_config($data = null) |
| 100 | 100 | { |
| 101 | 101 | return new TemplateRouteConfig($data); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | - * @return void |
|
| 106 | - */ |
|
| 105 | + * @return void |
|
| 106 | + */ |
|
| 107 | 107 | public function __invoke(RequestInterface $request, ResponseInterface $response) |
| 108 | 108 | { |
| 109 | 109 | unset($request); |
@@ -13,29 +13,29 @@ discard block |
||
| 13 | 13 | class TemplateRouteConfig extends RouteConfig |
| 14 | 14 | { |
| 15 | 15 | /** |
| 16 | - * The template ident (to load) |
|
| 17 | - * @var string $template |
|
| 18 | - */ |
|
| 16 | + * The template ident (to load) |
|
| 17 | + * @var string $template |
|
| 18 | + */ |
|
| 19 | 19 | private $template; |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | - * The view engine ident to use |
|
| 23 | - * Ex: "mustache", "" |
|
| 24 | - * @var string $engine |
|
| 25 | - */ |
|
| 22 | + * The view engine ident to use |
|
| 23 | + * Ex: "mustache", "" |
|
| 24 | + * @var string $engine |
|
| 25 | + */ |
|
| 26 | 26 | private $engine; |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | - * Additional template options |
|
| 30 | - * @var array $options |
|
| 31 | - */ |
|
| 29 | + * Additional template options |
|
| 30 | + * @var array $options |
|
| 31 | + */ |
|
| 32 | 32 | private $options; |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | - * @param string $template |
|
| 36 | - * @throws InvalidArgumentException |
|
| 37 | - * @return TemplateRouteConfig Chainable |
|
| 38 | - */ |
|
| 35 | + * @param string $template |
|
| 36 | + * @throws InvalidArgumentException |
|
| 37 | + * @return TemplateRouteConfig Chainable |
|
| 38 | + */ |
|
| 39 | 39 | public function set_template($template) |
| 40 | 40 | { |
| 41 | 41 | if ($template === null) { |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | - * @return string |
|
| 56 | - */ |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | 57 | public function template() |
| 58 | 58 | { |
| 59 | 59 | if ($this->template === null) { |
@@ -63,18 +63,18 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | - * @return string |
|
| 67 | - */ |
|
| 66 | + * @return string |
|
| 67 | + */ |
|
| 68 | 68 | public function default_template() |
| 69 | 69 | { |
| 70 | 70 | return $this->ident(); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | - * @param string $engine |
|
| 75 | - * @throws InvalidArgumentException |
|
| 76 | - * @return TemplateRouteConfig Chainable |
|
| 77 | - */ |
|
| 74 | + * @param string $engine |
|
| 75 | + * @throws InvalidArgumentException |
|
| 76 | + * @return TemplateRouteConfig Chainable |
|
| 77 | + */ |
|
| 78 | 78 | public function set_engine($engine) |
| 79 | 79 | { |
| 80 | 80 | if ($engine === null) { |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | - * @return string |
|
| 95 | - */ |
|
| 94 | + * @return string |
|
| 95 | + */ |
|
| 96 | 96 | public function engine() |
| 97 | 97 | { |
| 98 | 98 | if ($this->engine === null) { |
@@ -102,17 +102,17 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | - * @return string |
|
| 106 | - */ |
|
| 105 | + * @return string |
|
| 106 | + */ |
|
| 107 | 107 | public function default_engine() |
| 108 | 108 | { |
| 109 | 109 | return 'mustache'; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | - * @param array $options |
|
| 114 | - * @return TemplateRouteConfig Chainable |
|
| 115 | - */ |
|
| 113 | + * @param array $options |
|
| 114 | + * @return TemplateRouteConfig Chainable |
|
| 115 | + */ |
|
| 116 | 116 | public function set_options($options) |
| 117 | 117 | { |
| 118 | 118 | $this->options = $options; |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | - * @return array |
|
| 124 | - */ |
|
| 123 | + * @return array |
|
| 124 | + */ |
|
| 125 | 125 | public function options() |
| 126 | 126 | { |
| 127 | 127 | return $this->options; |
@@ -15,35 +15,35 @@ discard block |
||
| 15 | 15 | abstract class AbstractScript implements ScriptInterface |
| 16 | 16 | { |
| 17 | 17 | /** |
| 18 | - * @var string $ident |
|
| 19 | - */ |
|
| 18 | + * @var string $ident |
|
| 19 | + */ |
|
| 20 | 20 | private $ident; |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | - * @var string $description |
|
| 24 | - */ |
|
| 23 | + * @var string $description |
|
| 24 | + */ |
|
| 25 | 25 | private $description; |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | - * @var array $arguments |
|
| 29 | - */ |
|
| 28 | + * @var array $arguments |
|
| 29 | + */ |
|
| 30 | 30 | private $arguments; |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | - * @var CLImate $climate |
|
| 35 | - */ |
|
| 34 | + * @var CLImate $climate |
|
| 35 | + */ |
|
| 36 | 36 | private $climate; |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | - * @var boolean $verbose |
|
| 41 | - */ |
|
| 40 | + * @var boolean $verbose |
|
| 41 | + */ |
|
| 42 | 42 | private $verbose; |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | - * @return CLImate |
|
| 46 | - */ |
|
| 45 | + * @return CLImate |
|
| 46 | + */ |
|
| 47 | 47 | public function climate() |
| 48 | 48 | { |
| 49 | 49 | if ($this->climate === null) { |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | - * @return array |
|
| 57 | - */ |
|
| 56 | + * @return array |
|
| 57 | + */ |
|
| 58 | 58 | public function default_arguments() |
| 59 | 59 | { |
| 60 | 60 | return [ |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | - * @param string $ident |
|
| 77 | - * @throws InvalidArgumentException |
|
| 78 | - * @return ScriptInterface Chainable |
|
| 79 | - */ |
|
| 76 | + * @param string $ident |
|
| 77 | + * @throws InvalidArgumentException |
|
| 78 | + * @return ScriptInterface Chainable |
|
| 79 | + */ |
|
| 80 | 80 | public function set_ident($ident) |
| 81 | 81 | { |
| 82 | 82 | if (!is_string($ident)) { |
@@ -89,18 +89,18 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | - * @return string |
|
| 93 | - */ |
|
| 92 | + * @return string |
|
| 93 | + */ |
|
| 94 | 94 | public function ident() |
| 95 | 95 | { |
| 96 | 96 | return $this->ident; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | - * @param string $description |
|
| 101 | - * @throws InvalidArgumentException |
|
| 102 | - * @return ScriptInterface Chainable |
|
| 103 | - */ |
|
| 100 | + * @param string $description |
|
| 101 | + * @throws InvalidArgumentException |
|
| 102 | + * @return ScriptInterface Chainable |
|
| 103 | + */ |
|
| 104 | 104 | public function set_description($description) |
| 105 | 105 | { |
| 106 | 106 | if (!is_string($description)) { |
@@ -114,18 +114,18 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | - * @return string |
|
| 118 | - */ |
|
| 117 | + * @return string |
|
| 118 | + */ |
|
| 119 | 119 | public function description() |
| 120 | 120 | { |
| 121 | 121 | return $this->description; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | - * @param array $arguments |
|
| 126 | - * @throws InvalidArgumentException |
|
| 127 | - * @return ScriptInterface Chainable |
|
| 128 | - */ |
|
| 125 | + * @param array $arguments |
|
| 126 | + * @throws InvalidArgumentException |
|
| 127 | + * @return ScriptInterface Chainable |
|
| 128 | + */ |
|
| 129 | 129 | public function set_arguments($arguments) |
| 130 | 130 | { |
| 131 | 131 | if (!is_array($arguments)) { |
@@ -142,10 +142,10 @@ discard block |
||
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | - * @param string $argument_ident |
|
| 146 | - * @param array $argument |
|
| 147 | - * @return ScriptInterface Chainable |
|
| 148 | - */ |
|
| 145 | + * @param string $argument_ident |
|
| 146 | + * @param array $argument |
|
| 147 | + * @return ScriptInterface Chainable |
|
| 148 | + */ |
|
| 149 | 149 | public function add_argument($argument_ident, $argument) |
| 150 | 150 | { |
| 151 | 151 | $this->arguments[$argument_ident] = $argument; |
@@ -154,17 +154,17 @@ discard block |
||
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
| 157 | - * @return array $arguments |
|
| 158 | - */ |
|
| 157 | + * @return array $arguments |
|
| 158 | + */ |
|
| 159 | 159 | public function arguments() |
| 160 | 160 | { |
| 161 | 161 | return $this->arguments; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | - * @param string $argument_ident |
|
| 166 | - * @return array |
|
| 167 | - */ |
|
| 165 | + * @param string $argument_ident |
|
| 166 | + * @return array |
|
| 167 | + */ |
|
| 168 | 168 | public function argument($argument_ident) |
| 169 | 169 | { |
| 170 | 170 | if (!isset($this->arguments[$argument_ident])) { |
@@ -174,11 +174,11 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | - * Get an argument either from argument list (if set) or else from an input prompt. |
|
| 178 | - * |
|
| 179 | - * @param string $arg_name |
|
| 180 | - * @return string The argument value or prompt value |
|
| 181 | - */ |
|
| 177 | + * Get an argument either from argument list (if set) or else from an input prompt. |
|
| 178 | + * |
|
| 179 | + * @param string $arg_name |
|
| 180 | + * @return string The argument value or prompt value |
|
| 181 | + */ |
|
| 182 | 182 | public function arg_or_input($arg_name) |
| 183 | 183 | { |
| 184 | 184 | $climate = $this->climate(); |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | - * @param boolean $verbose |
|
| 217 | - * @throws InvalidArgumentException |
|
| 218 | - * @return CliActionTrait Chainable |
|
| 219 | - */ |
|
| 216 | + * @param boolean $verbose |
|
| 217 | + * @throws InvalidArgumentException |
|
| 218 | + * @return CliActionTrait Chainable |
|
| 219 | + */ |
|
| 220 | 220 | public function set_verbose($verbose) |
| 221 | 221 | { |
| 222 | 222 | if (!is_bool($verbose)) { |
@@ -229,16 +229,16 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | - * @return boolean |
|
| 233 | - */ |
|
| 232 | + * @return boolean |
|
| 233 | + */ |
|
| 234 | 234 | public function verbose() |
| 235 | 235 | { |
| 236 | 236 | return $this->verbose; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
| 240 | - * @return string |
|
| 241 | - */ |
|
| 240 | + * @return string |
|
| 241 | + */ |
|
| 242 | 242 | public function help() |
| 243 | 243 | { |
| 244 | 244 | return $this->climate()->usage(); |
@@ -8,24 +8,24 @@ |
||
| 8 | 8 | interface CronScriptInterface |
| 9 | 9 | { |
| 10 | 10 | /** |
| 11 | - * @param boolean $use_lock |
|
| 12 | - * @return CronScriptInterface Chainable |
|
| 13 | - */ |
|
| 11 | + * @param boolean $use_lock |
|
| 12 | + * @return CronScriptInterface Chainable |
|
| 13 | + */ |
|
| 14 | 14 | public function set_use_lock($use_lock); |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * @return boolean |
|
| 18 | - */ |
|
| 17 | + * @return boolean |
|
| 18 | + */ |
|
| 19 | 19 | public function use_lock(); |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | - * @throws Exception |
|
| 23 | - * @return boolean |
|
| 24 | - */ |
|
| 22 | + * @throws Exception |
|
| 23 | + * @return boolean |
|
| 24 | + */ |
|
| 25 | 25 | public function start_lock(); |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | - * |
|
| 29 | - */ |
|
| 28 | + * |
|
| 29 | + */ |
|
| 30 | 30 | public function stop_lock(); |
| 31 | 31 | } |
@@ -10,19 +10,19 @@ discard block |
||
| 10 | 10 | trait CronScriptTrait |
| 11 | 11 | { |
| 12 | 12 | /** |
| 13 | - * @var boolean $use_lock |
|
| 14 | - */ |
|
| 13 | + * @var boolean $use_lock |
|
| 14 | + */ |
|
| 15 | 15 | private $use_lock = false; |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * Lock file pointer |
|
| 19 | - * @var resource $lock_fp |
|
| 20 | - */ |
|
| 18 | + * Lock file pointer |
|
| 19 | + * @var resource $lock_fp |
|
| 20 | + */ |
|
| 21 | 21 | private $lock_fp; |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | - * |
|
| 25 | - */ |
|
| 24 | + * |
|
| 25 | + */ |
|
| 26 | 26 | public function set_cron_data(array $data) |
| 27 | 27 | { |
| 28 | 28 | if (isset($data['use_lock']) && $data['use_lock']) { |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | - * @param boolean $use_lock |
|
| 36 | - * @return CronScriptInterface Chainable |
|
| 37 | - */ |
|
| 35 | + * @param boolean $use_lock |
|
| 36 | + * @return CronScriptInterface Chainable |
|
| 37 | + */ |
|
| 38 | 38 | public function set_use_lock($use_lock) |
| 39 | 39 | { |
| 40 | 40 | $this->use_lock = !!$use_lock; |
@@ -42,26 +42,26 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | - * @return boolean |
|
| 46 | - */ |
|
| 45 | + * @return boolean |
|
| 46 | + */ |
|
| 47 | 47 | public function use_lock() |
| 48 | 48 | { |
| 49 | 49 | return $this->use_lock; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | - * @throws Exception |
|
| 54 | - * @return boolean |
|
| 55 | - */ |
|
| 53 | + * @throws Exception |
|
| 54 | + * @return boolean |
|
| 55 | + */ |
|
| 56 | 56 | public function start_lock() |
| 57 | 57 | { |
| 58 | 58 | $lock_name = str_replace('\\', '-', get_class($this)); |
| 59 | 59 | $lock_file = sys_get_temp_dir().'/'.$lock_name; |
| 60 | 60 | $this->lock_fp = fopen($lock_file, 'w'); |
| 61 | 61 | if (!$this->lock_fp) { |
| 62 | - throw new Exception( |
|
| 63 | - 'Can not run action. Lock file not available.' |
|
| 64 | - ); |
|
| 62 | + throw new Exception( |
|
| 63 | + 'Can not run action. Lock file not available.' |
|
| 64 | + ); |
|
| 65 | 65 | } |
| 66 | 66 | if (flock($this->lock_fp, LOCK_EX)) { |
| 67 | 67 | return true; |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | - * |
|
| 77 | - */ |
|
| 76 | + * |
|
| 77 | + */ |
|
| 78 | 78 | public function stop_lock() |
| 79 | 79 | { |
| 80 | 80 | if ($this->lock_fp) { |