1
1
<?php
2
+
2
3
declare (strict_types=1 );
3
4
4
5
namespace MaplePHP \Unitary ;
13
14
14
15
class FileIterator
15
16
{
16
- const PATTERN = 'unitary-*.php ' ;
17
+ public const PATTERN = 'unitary-*.php ' ;
17
18
18
19
private array $ args ;
19
20
@@ -74,7 +75,7 @@ private function findFiles(string $dir): array
74
75
$ pattern = static ::PATTERN ;
75
76
foreach ($ iterator as $ file ) {
76
77
if (($ file instanceof SplFileInfo) && fnmatch ($ pattern , $ file ->getFilename ()) &&
77
- (isset ($ this ->args ['path ' ]) || !str_contains ($ file ->getPathname (), DIRECTORY_SEPARATOR . "vendor " . DIRECTORY_SEPARATOR ))) {
78
+ (isset ($ this ->args ['path ' ]) || !str_contains ($ file ->getPathname (), DIRECTORY_SEPARATOR . "vendor " . DIRECTORY_SEPARATOR ))) {
78
79
if (!$ this ->findExcluded ($ this ->exclude (), $ dir , $ file ->getPathname ())) {
79
80
$ files [] = $ file ->getPathname ();
80
81
}
@@ -87,9 +88,9 @@ private function findFiles(string $dir): array
87
88
* Get exclude parameter
88
89
* @return array
89
90
*/
90
- function exclude (): array
91
+ public function exclude (): array
91
92
{
92
- $ excl = array () ;
93
+ $ excl = [] ;
93
94
if (isset ($ this ->args ['exclude ' ]) && is_string ($ this ->args ['exclude ' ])) {
94
95
$ exclude = explode (', ' , $ this ->args ['exclude ' ]);
95
96
foreach ($ exclude as $ file ) {
@@ -112,7 +113,7 @@ function exclude(): array
112
113
* @param string $file
113
114
* @return bool
114
115
*/
115
- function findExcluded (array $ exclArr , string $ relativeDir , string $ file ): bool
116
+ public function findExcluded (array $ exclArr , string $ relativeDir , string $ file ): bool
116
117
{
117
118
$ file = $ this ->getNaturalPath ($ file );
118
119
foreach ($ exclArr as $ excl ) {
@@ -129,7 +130,7 @@ function findExcluded(array $exclArr, string $relativeDir, string $file): bool
129
130
* @param string $path
130
131
* @return string
131
132
*/
132
- function getNaturalPath (string $ path ): string
133
+ public function getNaturalPath (string $ path ): string
133
134
{
134
135
return str_replace ("\\" , "/ " , $ path );
135
136
}
@@ -142,8 +143,7 @@ function getNaturalPath(string $path): string
142
143
private function requireUnitFile (string $ file ): ?Closure
143
144
{
144
145
$ clone = clone $ this ;
145
- $ call = function () use ($ file , $ clone ): void
146
- {
146
+ $ call = function () use ($ file , $ clone ): void {
147
147
$ cli = new CliHandler ();
148
148
if (isset (self ::$ headers ['args ' ]['trace ' ])) {
149
149
$ cli ->enableTraceLines (true );
@@ -155,7 +155,7 @@ private function requireUnitFile(string $file): ?Closure
155
155
if (!is_file ($ file )) {
156
156
throw new RuntimeException ("File \"$ file \" do not exists. " );
157
157
}
158
- require_once ($ file );
158
+ require_once ($ file );
159
159
160
160
$ clone ->getUnit ()->execute ();
161
161
@@ -180,4 +180,4 @@ protected function getUnit(): Unit
180
180
return $ unit ;
181
181
182
182
}
183
- }
183
+ }
0 commit comments