1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the O2System PHP 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\Reactor\Cli\Commanders\Make; |
15
|
|
|
|
16
|
|
|
// ------------------------------------------------------------------------ |
17
|
|
|
|
18
|
|
|
use O2System\Reactor\Cli\Commanders\Make; |
19
|
|
|
use O2System\Kernel\Cli\Writers\Format; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class Helper |
23
|
|
|
* |
24
|
|
|
* @package O2System\Reactor\Cli\Commanders\Make |
25
|
|
|
*/ |
26
|
|
|
class Helper extends Make |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Helper::$commandDescription |
30
|
|
|
* |
31
|
|
|
* Command description. |
32
|
|
|
* |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $commandDescription = 'CLI_MAKE_HELPER_DESC'; |
36
|
|
|
|
37
|
|
|
// ------------------------------------------------------------------------ |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Helper::execute |
41
|
|
|
* |
42
|
|
|
* @throws \ReflectionException |
43
|
|
|
*/ |
44
|
|
|
public function execute() |
45
|
|
|
{ |
46
|
|
|
$this->__callOptions(); |
47
|
|
|
|
48
|
|
|
if (empty($this->optionFilename)) { |
49
|
|
|
output()->write( |
|
|
|
|
50
|
|
|
(new Format()) |
51
|
|
|
->setContextualClass(Format::DANGER) |
52
|
|
|
->setString(language()->getLine('CLI_MAKE_HELPER_E_FILENAME')) |
53
|
|
|
->setNewLinesAfter(1) |
54
|
|
|
); |
55
|
|
|
|
56
|
|
|
exit(EXIT_ERROR); |
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
if (strpos($this->optionPath, 'Helpers') === false) { |
60
|
|
|
$filePath = $this->optionPath . 'Helpers' . DIRECTORY_SEPARATOR . $this->optionFilename; |
61
|
|
|
} else { |
62
|
|
|
$filePath = $this->optionPath . $this->optionFilename; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
if ( ! is_dir(dirname($filePath))) { |
66
|
|
|
mkdir(dirname($filePath), 0777, true); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
if (is_file($filePath)) { |
70
|
|
|
output()->write( |
71
|
|
|
(new Format()) |
72
|
|
|
->setContextualClass(Format::DANGER) |
73
|
|
|
->setString(language()->getLine('CLI_MAKE_HELPER_E_EXISTS', [$filePath])) |
74
|
|
|
->setNewLinesAfter(1) |
75
|
|
|
); |
76
|
|
|
|
77
|
|
|
exit(EXIT_ERROR); |
|
|
|
|
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
$vars[ 'CREATE_DATETIME' ] = date('d/m/Y H:m'); |
|
|
|
|
81
|
|
|
$vars[ 'HELPER' ] = underscore( |
82
|
|
|
snakecase( |
83
|
|
|
pathinfo($filePath, PATHINFO_FILENAME) |
84
|
|
|
) |
85
|
|
|
); |
86
|
|
|
$vars[ 'FILEPATH' ] = $filePath; |
87
|
|
|
|
88
|
|
|
$phpTemplate = <<<PHPTEMPLATE |
89
|
|
|
<?php |
90
|
|
|
/** |
91
|
|
|
* Created by O2System Reactor File Generator. |
92
|
|
|
* DateTime: CREATE_DATETIME |
93
|
|
|
*/ |
94
|
|
|
|
95
|
|
|
// ------------------------------------------------------------------------ |
96
|
|
|
|
97
|
|
|
if ( ! function_exists( 'HELPER' ) ) { |
98
|
|
|
/** |
99
|
|
|
* HELPER |
100
|
|
|
*/ |
101
|
|
|
function HELPER() { |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
PHPTEMPLATE; |
105
|
|
|
|
106
|
|
|
$fileContent = str_replace(array_keys($vars), array_values($vars), $phpTemplate); |
107
|
|
|
file_put_contents($filePath, $fileContent); |
108
|
|
|
|
109
|
|
|
if (is_file($filePath)) { |
110
|
|
|
output()->write( |
111
|
|
|
(new Format()) |
112
|
|
|
->setContextualClass(Format::SUCCESS) |
113
|
|
|
->setString(language()->getLine('CLI_MAKE_HELPER_S_MAKE', [$filePath])) |
114
|
|
|
->setNewLinesAfter(1) |
115
|
|
|
); |
116
|
|
|
|
117
|
|
|
exit(EXIT_SUCCESS); |
|
|
|
|
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
} |
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.