Completed
Push — master ( b25a31...347863 )
by Jakub
01:41
created

ContainerSuiteFactory::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 6
ccs 0
cts 5
cp 0
crap 6
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace MyTester\Bridges\NetteDI;
5
6
use MyTester\TestCase;
7
use Nette\DI\Container;
8
use RuntimeException;
9
10
/**
11
 * @author Jakub Konečný
12
 * @internal
13
 */
14
final class ContainerSuiteFactory implements \MyTester\ITestSuiteFactory {
15
  private Container $container;
16
17
  public function __construct(Container $container) {
18
    $this->container = $container;
19
  }
20
21
  public function create(string $className): TestCase {
22
    $suit = $this->container->getByType($className);
23
    if(!$suit instanceof TestCase) {
24
      throw new RuntimeException("$className is not a descendant of " . TestCase::class . ".");
25
    }
26
    return $suit;
27
  }
28
}
29
?>