Passed
Push — master ( aa061c...2e1140 )
by Jakub
02:07
created

ContainerSuiteFactory   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 7
c 3
b 0
f 0
dl 0
loc 24
rs 10
ccs 7
cts 7
cp 1
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 8 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MyTester\Bridges\NetteDI;
6
7
use MyTester\InvalidTestCaseException;
8
use MyTester\TestCase;
9
10
/**
11
 * @author Jakub Konečný
12
 * @internal
13
 */
14
final class ContainerSuiteFactory implements \MyTester\ITestSuiteFactory
15
{
16
    /** @var TestCase[] */
17
    private array $suites;
18
19
    /**
20
     * @param TestCase[] $suites
21
     */
22 1
    public function __construct(array $suites)
23
    {
24 1
        $this->suites = $suites;
25
    }
26
27
  /**
28
   * @param class-string $className
29
   */
30 1
    public function create(string $className): TestCase
31
    {
32 1
        foreach ($this->suites as $suite) {
33 1
            if ($suite instanceof $className && $suite instanceof TestCase) {
34 1
                return $suite;
35
            }
36
        }
37 1
        throw new InvalidTestCaseException("$className is not a descendant of " . TestCase::class . ".");
38
    }
39
}
40