|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Povils\PHPMND\Console; |
|
4
|
|
|
|
|
5
|
|
|
use Povils\PHPMND\Extension\Extension; |
|
6
|
|
|
use Povils\PHPMND\Language; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @package Povils\PHPMND\Console |
|
10
|
|
|
*/ |
|
11
|
|
|
class Option |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var Extension[] |
|
15
|
|
|
*/ |
|
16
|
|
|
private $extensions = []; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var array |
|
20
|
|
|
*/ |
|
21
|
|
|
private $ignoreNumbers = [0, 0., 1]; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var array |
|
25
|
|
|
*/ |
|
26
|
|
|
private $ignoreFuncs = [ |
|
27
|
|
|
'intval', |
|
28
|
|
|
'floatval', |
|
29
|
|
|
'strval', |
|
30
|
|
|
]; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var array |
|
34
|
|
|
*/ |
|
35
|
|
|
private $ignoreStrings = ['', '0', '1']; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var bool |
|
39
|
|
|
*/ |
|
40
|
|
|
private $includeStrings = false; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var bool |
|
44
|
|
|
*/ |
|
45
|
|
|
private $giveHint = false; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var bool |
|
49
|
|
|
*/ |
|
50
|
|
|
private $includeNumericStrings = false; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @var bool |
|
54
|
|
|
*/ |
|
55
|
|
|
private $allowArrayMapping = false; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @var array |
|
59
|
|
|
*/ |
|
60
|
|
|
private $checkNaming = []; |
|
61
|
|
|
|
|
62
|
|
|
public function setExtensions(array $extensions) |
|
63
|
|
|
{ |
|
64
|
|
|
$this->extensions = $extensions; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function getExtensions(): array |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->extensions; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function setIgnoreNumbers(array $ignoreNumbers) |
|
73
|
|
|
{ |
|
74
|
|
|
$this->ignoreNumbers = array_merge($this->ignoreNumbers, $ignoreNumbers); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function getIgnoreNumbers(): array |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->ignoreNumbers; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function setIgnoreFuncs(array $ignoreFuncs) |
|
83
|
|
|
{ |
|
84
|
|
|
$this->ignoreFuncs = $ignoreFuncs; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function getIgnoreFuncs(): array |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->ignoreFuncs; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function includeStrings(): ?bool |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->includeStrings; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function setIncludeStrings(?bool $includeStrings) |
|
98
|
|
|
{ |
|
99
|
|
|
$this->includeStrings = $includeStrings; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function getIgnoreStrings(): array |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->ignoreStrings; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public function setIgnoreStrings(array $ignoreStrings) |
|
108
|
|
|
{ |
|
109
|
|
|
$this->ignoreStrings = array_merge($this->ignoreStrings, $ignoreStrings); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
public function giveHint(): bool |
|
113
|
|
|
{ |
|
114
|
|
|
return $this->giveHint; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
public function setGiveHint(bool $giveHint) |
|
118
|
|
|
{ |
|
119
|
|
|
$this->giveHint = $giveHint; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
public function includeNumericStrings(): ?bool |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->includeNumericStrings; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
public function setIncludeNumericStrings(?bool $includeNumericStrings) |
|
128
|
|
|
{ |
|
129
|
|
|
$this->includeNumericStrings = $includeNumericStrings; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
public function allowArrayMapping(): ?bool |
|
133
|
|
|
{ |
|
134
|
|
|
return $this->allowArrayMapping; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
public function setAllowArrayMapping(?bool $allowArrayMapping) |
|
138
|
|
|
{ |
|
139
|
|
|
$this->allowArrayMapping = $allowArrayMapping; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* @return Language[] |
|
144
|
|
|
*/ |
|
145
|
|
|
public function checkNaming(): array |
|
146
|
|
|
{ |
|
147
|
|
|
return $this->checkNaming; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
public function setCheckNaming(array $checkNaming) |
|
151
|
|
|
{ |
|
152
|
|
|
$languages = []; |
|
153
|
|
|
foreach ($checkNaming as $language) { |
|
154
|
|
|
$language = ucfirst($language); |
|
155
|
|
|
$className = '\Povils\PHPMND\Languages\\' . $language; |
|
156
|
|
|
|
|
157
|
|
|
if (class_exists($className)) { |
|
158
|
|
|
$languages[] = new $className(); |
|
159
|
|
|
} |
|
160
|
|
|
} |
|
161
|
|
|
$this->checkNaming = $languages; |
|
162
|
|
|
} |
|
163
|
|
|
} |
|
164
|
|
|
|