@@ -5,7 +5,7 @@ class ComplianceValidator
55{
66 const STATE_OPTIONAL_NOT_PRESENT = 1 ;
77 const STATE_CORRECT_PRESENT = 2 ;
8- const STATE_REQUIRED_NOT_PRESENT = 3 ;
8+ const STATE_RECOMMENDED_NOT_PRESENT = 3 ;
99 const STATE_INCORRECT_PRESENT = 4 ;
1010
1111 protected $ files = null ;
@@ -28,7 +28,6 @@ public function validate($lines)
2828 "Other resource files " => $ this ->checkResources ($ lines ),
2929 "PHP source code " => $ this ->checkSrc ($ lines ),
3030 "Test code " => $ this ->checkTests ($ lines ),
31- "Package managers " => $ this ->checkVendor ($ lines ),
3231 "Log of changes between releases " => $ this ->checkChangelog ($ lines ),
3332 "Guidelines for contributors " => $ this ->checkContributing ($ lines ),
3433 "Licensing information " => $ this ->checkLicense ($ lines ),
@@ -81,7 +80,7 @@ protected function outputResultLine($label, $complianceState, $expected, $actual
8180 self ::STATE_OPTIONAL_NOT_PRESENT => "Optional {$ expected } not present " ,
8281 self ::STATE_CORRECT_PRESENT => "Correct {$ actual } present " ,
8382 self ::STATE_INCORRECT_PRESENT => "Incorrect {$ actual } present " ,
84- self ::STATE_REQUIRED_NOT_PRESENT => "Required {$ expected } not present " ,
83+ self ::STATE_RECOMMENDED_NOT_PRESENT => "Recommended {$ expected } not present " ,
8584 ];
8685 echo $ this ->colorConsoleText ("- " . $ label . ": " . $ messages [$ complianceState ], $ complianceState ) . PHP_EOL ;
8786 }
@@ -92,7 +91,7 @@ protected function colorConsoleText($text, $complianceState)
9291 self ::STATE_OPTIONAL_NOT_PRESENT => "\033[43;30m " ,
9392 self ::STATE_CORRECT_PRESENT => "\033[42;30m " ,
9493 self ::STATE_INCORRECT_PRESENT => "\033[41m " ,
95- self ::STATE_REQUIRED_NOT_PRESENT => "\033[41m " ,
94+ self ::STATE_RECOMMENDED_NOT_PRESENT => "\033[41m " ,
9695 ];
9796 if (!array_key_exists ($ complianceState , $ colors )) {
9897 return $ text ;
@@ -114,7 +113,7 @@ protected function checkDir($lines, $pass, array $fail)
114113 return [self ::STATE_OPTIONAL_NOT_PRESENT , $ pass , null ];
115114 }
116115
117- protected function checkFile ($ lines , $ pass , array $ fail )
116+ protected function checkFile ($ lines , $ pass , array $ fail, $ state = self :: STATE_OPTIONAL_NOT_PRESENT )
118117 {
119118 foreach ($ lines as $ line ) {
120119 $ line = trim ($ line );
@@ -127,18 +126,7 @@ protected function checkFile($lines, $pass, array $fail)
127126 }
128127 }
129128 }
130- return [self ::STATE_OPTIONAL_NOT_PRESENT , $ pass , null ];
131- }
132-
133- protected function checkVendor ($ lines , $ pass = 'vendor/ ' )
134- {
135- foreach ($ lines as $ line ) {
136- $ line = trim ($ line );
137- if ($ line == $ pass ) {
138- return [self ::STATE_CORRECT_PRESENT , $ pass , $ line ];
139- }
140- }
141- return [self ::STATE_REQUIRED_NOT_PRESENT , $ pass , null ];
129+ return [$ state , $ pass , null ];
142130 }
143131
144132 protected function checkChangelog ($ lines )
@@ -168,13 +156,18 @@ protected function checkContributing($lines)
168156
169157 protected function checkLicense ($ lines )
170158 {
171- return $ this ->checkFile ($ lines , 'LICENSE ' , [
172- '/^.*EULA.*$/i ' ,
173- '/^.*(GPL|BSD).*$/i ' ,
174- '/^([A-Z-]+)?LI(N)?(S|C)(E|A)N(S|C)(E|A)(_[A-Z_]+)?(\.[a-z]+)?$/i ' ,
175- '/^COPY(I)?NG(\.[a-z]+)?$/i ' ,
176- '/^COPYRIGHT(\.[a-z]+)?$/i ' ,
177- ]);
159+ return $ this ->checkFile (
160+ $ lines ,
161+ 'LICENSE ' ,
162+ [
163+ '/^.*EULA.*$/i ' ,
164+ '/^.*(GPL|BSD).*$/i ' ,
165+ '/^([A-Z-]+)?LI(N)?(S|C)(E|A)N(S|C)(E|A)(_[A-Z_]+)?(\.[a-z]+)?$/i ' ,
166+ '/^COPY(I)?NG(\.[a-z]+)?$/i ' ,
167+ '/^COPYRIGHT(\.[a-z]+)?$/i ' ,
168+ ],
169+ self ::STATE_RECOMMENDED_NOT_PRESENT
170+ );
178171 }
179172
180173 protected function checkReadme ($ lines )
0 commit comments