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

ContainerSuiteFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 6 2
A __construct() 0 2 1
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
?>