InterfaceContextTrait::assertInterfaceNotExists()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
/**
3
 * This file is part of the phpspec-behavior package.
4
 * (c) 2017 Timo Michna <timomichna/yahoo.de>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace features\Behavior\Context\CodeGeneration;
11
12
use Hamcrest\MatcherAssert as Matcher;
13
14
trait InterfaceContextTrait
15
{
16
    /**
17
     * @Given the interface :interfaceName does exist
18
     *
19
     * @param $interfaceName
20
     */
21
    public function theInterfaceDoesExist($interfaceName)
22
    {
23
        $this->assertInterfaceExists($interfaceName);
24
    }
25
26
    /**
27
     * @Given the interface :interfaceName does not exist
28
     *
29
     * @param $interfaceName
30
     */
31
    public function theInterfaceDoesNotExist(string $interfaceName)
32
    {
33
        $this->assertInterfaceNotExists($interfaceName);
34
    }
35
36
    protected function assertInterfaceExists(string $interfaceName)
37
    {
38
        Matcher::assertThat(
39
            sprintf(
40
                'interface %s should exist',
41
                $interfaceName
42
            ),
43
            interface_exists($interfaceName)
44
        );
45
    }
46
47
    protected function assertInterfaceNotExists(string $interfaceName)
48
    {
49
        Matcher::assertThat(
50
            sprintf(
51
                'interface %s should not exist',
52
                $interfaceName
53
            ),
54
            !interface_exists($interfaceName)
55
        );
56
    }
57
}
58
59