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

ComposerTestSuitsFinder::getSuits()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 4
eloc 10
c 1
b 0
f 1
nc 3
nop 1
dl 0
loc 14
rs 9.9332
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
?>