File tree 6 files changed +38
-13
lines changed
6 files changed +38
-13
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ use Arkitect\Expression\ForClasses\ResideInOneOfTheseNamespaces;
118
118
use Arkitect\Rules\Rule;
119
119
120
120
return static function (Config $config): void {
121
- $mvcClassSet = ClassSet::fromDir(__DIR__.'/mvc');
121
+ $mvcClassSet = ClassSet::fromDir(__DIR__.'/mvc', __DIR__.'/lib/my-lib/src' );
122
122
123
123
$rules = [];
124
124
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public function __construct(OutputInterface $output)
17
17
18
18
public function startFileSetAnalysis (ClassSet $ set ): void
19
19
{
20
- $ this ->output ->writeln ("Start analyze dir {$ set ->getDir ()}" );
20
+ $ this ->output ->writeln ("Start analyze dirs {$ set ->getDirsDescription ()}" );
21
21
}
22
22
23
23
public function startParsingFile (string $ file ): void
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public function __construct(OutputInterface $output)
33
33
34
34
public function startFileSetAnalysis (ClassSet $ set ): void
35
35
{
36
- $ this ->output ->writeln ("analyze class set {$ set ->getDir ()}" );
36
+ $ this ->output ->writeln ("analyze class set {$ set ->getDirsDescription ()}" );
37
37
$ this ->output ->writeln ('' );
38
38
$ this ->progress = new ProgressBar ($ this ->output , iterator_count ($ set ));
39
39
Original file line number Diff line number Diff line change 11
11
*/
12
12
class ClassSet implements \IteratorAggregate
13
13
{
14
- private string $ directory ;
14
+ /** @var string[] */
15
+ private array $ directoryList ;
15
16
16
17
private array $ exclude ;
17
18
18
- private function __construct (string $ directory )
19
+ private function __construct (string ... $ directoryList )
19
20
{
20
- $ this ->directory = $ directory ;
21
+ $ this ->directoryList = $ directoryList ;
21
22
$ this ->exclude = [];
22
23
}
23
24
@@ -28,21 +29,21 @@ public function excludePath(string $pattern): self
28
29
return $ this ;
29
30
}
30
31
31
- public static function fromDir (string $ directory ): self
32
+ public static function fromDir (string ... $ directoryList ): self
32
33
{
33
- return new self ($ directory );
34
+ return new self (... $ directoryList );
34
35
}
35
36
36
- public function getDir (): string
37
+ public function getDirsDescription (): string
37
38
{
38
- return $ this ->directory ;
39
+ return implode ( ' , ' , $ this ->directoryList ) ;
39
40
}
40
41
41
42
public function getIterator (): \Traversable
42
43
{
43
44
$ finder = (new Finder ())
44
45
->files ()
45
- ->in ($ this ->directory )
46
+ ->in ($ this ->directoryList )
46
47
->name ('*.php ' )
47
48
->sortByName ()
48
49
->followLinks ()
Original file line number Diff line number Diff line change @@ -28,8 +28,8 @@ public function test_it_should_generate_text_on_start_file_set_analysis(): void
28
28
$ output = $ this ->prophesize (OutputInterface::class);
29
29
$ debugProgress = new DebugProgress ($ output ->reveal ());
30
30
31
- $ output ->writeln ('Start analyze dir directory ' )->shouldBeCalled ();
32
- $ debugProgress ->startFileSetAnalysis (ClassSet::fromDir ('directory ' ));
31
+ $ output ->writeln ('Start analyze dirs directory1, directory2 ' )->shouldBeCalled ();
32
+ $ debugProgress ->startFileSetAnalysis (ClassSet::fromDir ('directory1 ' , ' directory2 ' ));
33
33
}
34
34
35
35
public function test_it_should_not_generate_text_on_end_parsing_file (): void
Original file line number Diff line number Diff line change 10
10
11
11
class ClassSetTest extends TestCase
12
12
{
13
+ public function test_can_exclude_files_or_directories_from_multiple_dir_class_set (): void
14
+ {
15
+ $ path = $ this ->createMvcProjectStructure ();
16
+
17
+ $ set = ClassSet::fromDir ($ path .'/Controller ' , $ path .'/Model ' )
18
+ ->excludePath ('Repository ' );
19
+
20
+ $ expected = [
21
+ $ path .'/Controller/CatalogController.php ' ,
22
+ $ path .'/Controller/Foo.php ' ,
23
+ $ path .'/Controller/ProductsController.php ' ,
24
+ $ path .'/Controller/UserController.php ' ,
25
+ $ path .'/Controller/YieldController.php ' ,
26
+ $ path .'/Model/Catalog.php ' ,
27
+ $ path .'/Model/Products.php ' ,
28
+ $ path .'/Model/User.php ' ,
29
+ ];
30
+ $ actual = array_values (array_map (function ($ item ) {
31
+ /** @var \SplFileInfo $item */
32
+ return $ item ->getPathname ();
33
+ }, iterator_to_array ($ set )));
34
+ self ::assertEquals ($ expected , $ actual );
35
+ }
36
+
13
37
public function test_can_exclude_files_or_directories (): void
14
38
{
15
39
$ path = $ this ->createMvcProjectStructure ();
You can’t perform that action at this time.
0 commit comments