Completed
Push — master ( 5ee203...6d56e3 )
by Jakub
01:40
created

ComposerTestSuitsFinder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
c 1
b 0
f 1
dl 0
loc 15
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSuits() 0 14 4
1
<?php
2
declare(strict_types=1);
3
4
namespace MyTester;
5
6
use hanneskod\classtools\Iterator\ClassIterator;
7
use ReflectionClass;
8
use Symfony\Component\Finder\Finder;
9
10
/**
11
 * @author Jakub Konečný
12
 * @internal
13
 */
14
final class ComposerTestSuitsFinder implements ITestsSuitsFinder {
15
  public function getSuits(string $folder): array {
16
    $suits = [];
17
    $finder = new Finder();
18
    $iterator = new ClassIterator($finder->in($folder));
19
    $iterator->enableAutoloading();
20
    /** @var ReflectionClass $class */
21
    foreach($iterator->type(TestCase::class) as $class) {
22
      $filename = (string) $class->getFileName();
23
      if(!$class->isInstantiable() || !str_ends_with($filename, "Test.php")) {
24
        continue;
25
      }
26
      $suits[] = [$class->getName(), $filename];
27
    }
28
    return $suits;
29
  }
30
}
31
?>