ServiceContext   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 8
c 0
b 0
f 0
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A serviceShouldExist() 0 5 1
A iConfigurePhpSpecWith() 0 5 1
1
<?php
2
3
4
namespace Doyo\PhpSpec\CodeCoverage\Context;
5
6
7
use Behat\Behat\Context\Context;
8
use Behat\Gherkin\Node\PyStringNode;
9
use PhpSpec\Console\Command\RunCommand;
10
use PhpSpec\Exception\Configuration\InvalidConfigurationException;
11
use PhpSpec\Extension;
12
use PhpSpec\Matcher\Matcher;
13
use PhpSpec\ServiceContainer;
14
use PhpSpec\ServiceContainer\IndexedServiceContainer;
15
use Symfony\Component\Console\Command\Command;
16
use Symfony\Component\Console\Input\StringInput;
17
use Symfony\Component\Yaml\Yaml;
18
use Webmozart\Assert\Assert;
19
20
class ServiceContext implements Context
21
{
22
    /**
23
     * @var Application
24
     */
25
    private $app;
26
27
    /**
28
     * @Then service :name should exist
29
     *
30
     * @param string $name
31
     */
32
    public function serviceShouldExist($name)
33
    {
34
        $container = $this->app->getContainer();
35
        Assert::true($container->has($name));
36
        Assert::true(is_object($container->get($name)));
37
    }
38
39
    /**
40
     * @Given I configure phpspec with:
41
     *
42
     * @param PyStringNode $node
43
     */
44
    public function iConfigurePhpSpecWith(PyStringNode $node)
45
    {
46
        $config = Yaml::parse($node->getRaw());
47
        $app = new Application($config);
48
        $this->app = $app;
49
    }
50
}