Completed
Push — master ( 531aca...edc713 )
by Kamil
04:19
created

UninitialisedContextServiceEnvironment   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 48
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
/*
4
 * This file is part of the ContextServiceExtension package.
5
 *
6
 * (c) FriendsOfBehat
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FriendsOfBehat\ContextServiceExtension\Context\Environment;
13
14
use Behat\Testwork\Environment\StaticEnvironment;
15
use FriendsOfBehat\ContextServiceExtension\Context\Environment\Handler\ContextServiceEnvironmentHandler;
16
17
/**
18
 * @internal
19
 *
20
 * @see ContextServiceEnvironmentHandler
21
 */
22
final class UninitialisedContextServiceEnvironment extends StaticEnvironment implements ContextServiceEnvironment
23
{
24
    /**
25
     * @var string[]
26
     */
27
    private $contextServices = [];
28
29
    /**
30
     * @param string $serviceId
31
     * @param string $serviceClass
32
     */
33
    public function registerContextService($serviceId, $serviceClass)
34
    {
35
        $this->contextServices[$serviceId] = $serviceClass;
36
    }
37
38
    /**
39
     * @return array[]
40
     */
41
    public function getContextServices()
42
    {
43
        return array_keys($this->contextServices);
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function hasContexts()
50
    {
51
        return count($this->contextServices) > 0;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function getContextClasses()
58
    {
59
        return array_values($this->contextServices);
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function hasContextClass($class)
66
    {
67
        return array_search($class, $this->contextServices, true);
0 ignored issues
show
Bug Compatibility introduced by
The expression array_search($class, $th...contextServices, true); of type false|integer adds the type integer to the return on line 67 which is incompatible with the return type declared by the interface Behat\Behat\Context\Envi...onment::hasContextClass of type boolean.
Loading history...
68
    }
69
}
70