Passed
Push — master ( 11230f...5f5cdb )
by Jakub
12:32
created

ContainerSuiteFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 2
b 0
f 0
dl 0
loc 19
ccs 6
cts 7
cp 0.8571
rs 10

2 Methods

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