|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the O2System Framework package. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
* |
|
8
|
|
|
* @author Steeve Andrian Salim |
|
9
|
|
|
* @copyright Copyright (c) Steeve Andrian Salim |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
// ------------------------------------------------------------------------ |
|
13
|
|
|
|
|
14
|
|
|
namespace O2System\Kernel\Cli; |
|
15
|
|
|
|
|
16
|
|
|
// ------------------------------------------------------------------------ |
|
17
|
|
|
|
|
18
|
|
|
use O2System\Kernel\Cli\Abstracts\AbstractCommander; |
|
19
|
|
|
use O2System\Kernel\Cli\Writers\Format; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Class Commander |
|
23
|
|
|
* |
|
24
|
|
|
* @package O2System\Framework\Abstracts |
|
25
|
|
|
*/ |
|
26
|
|
|
abstract class Commander extends AbstractCommander |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* Commander::$app |
|
30
|
|
|
* |
|
31
|
|
|
* Commander cli-app. |
|
32
|
|
|
* |
|
33
|
|
|
* @var App |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $app; |
|
36
|
|
|
|
|
37
|
|
|
// ------------------------------------------------------------------------ |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Commander::setApp |
|
41
|
|
|
* |
|
42
|
|
|
* @param \O2System\Kernel\Cli\App $app |
|
43
|
|
|
*/ |
|
44
|
|
|
public function setApp(App $app) |
|
45
|
|
|
{ |
|
46
|
|
|
$this->app = $app; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
// ------------------------------------------------------------------------ |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Commander::optionVersion |
|
53
|
|
|
* |
|
54
|
|
|
* Option version method, write commander version string. |
|
55
|
|
|
* |
|
56
|
|
|
* @return void |
|
57
|
|
|
*/ |
|
58
|
|
|
public function optionVersion() |
|
59
|
|
|
{ |
|
60
|
|
|
if (property_exists($this, 'commandVersion')) { |
|
61
|
|
|
if ( ! empty($this->commandVersion)) { |
|
62
|
|
|
// Show Name & Version Line |
|
63
|
|
|
output()->write( |
|
|
|
|
|
|
64
|
|
|
(new Format()) |
|
65
|
|
|
->setString($this->optionVersion() . ucfirst($this->commandName) . ' v' . $this->commandVersion) |
|
|
|
|
|
|
66
|
|
|
->setNewLinesAfter(1) |
|
67
|
|
|
); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
// ------------------------------------------------------------------------ |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Commander::__call |
|
76
|
|
|
* |
|
77
|
|
|
* @param string $method |
|
78
|
|
|
* @param array $args |
|
79
|
|
|
* |
|
80
|
|
|
* @return mixed |
|
81
|
|
|
*/ |
|
82
|
|
|
public function __call($method, array $args = []) |
|
83
|
|
|
{ |
|
84
|
|
|
if (method_exists($this, $method)) { |
|
85
|
|
|
return call_user_func_array([$this, $method], $args); |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
} |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.