Completed
Push — master ( 3ef0d0...50fc50 )
by Kamil
07:01
created

UninitialisedContextServiceEnvironment   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 30
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A registerContextService() 0 4 1
A getContextServices() 0 4 1
A hasContexts() 0 4 1
A getContextClasses() 0 4 1
A hasContextClass() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the SymfonyExtension package.
7
 *
8
 * (c) Kamil Kokot <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace FriendsOfBehat\SymfonyExtension\Context\Environment;
15
16
use Behat\Testwork\Environment\StaticEnvironment;
17
use FriendsOfBehat\SymfonyExtension\Context\Environment\Handler\ContextServiceEnvironmentHandler;
18
19
/**
20
 * @see ContextServiceEnvironmentHandler
21
 */
22
final class UninitialisedContextServiceEnvironment extends StaticEnvironment implements ContextServiceEnvironment
23
{
24
    /** @var string[] */
25
    private $contextServices = [];
26
27
    public function registerContextService(string $serviceId, string $serviceClass): void
28
    {
29
        $this->contextServices[$serviceId] = $serviceClass;
30
    }
31
32
    public function getContextServices(): array
33
    {
34
        return array_keys($this->contextServices);
35
    }
36
37
    public function hasContexts(): bool
38
    {
39
        return count($this->contextServices) > 0;
40
    }
41
42
    public function getContextClasses(): array
43
    {
44
        return array_values($this->contextServices);
45
    }
46
47
    public function hasContextClass($class): bool
48
    {
49
        return in_array($class, $this->contextServices, true);
50
    }
51
}
52