PantherFactory::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 6
ccs 0
cts 4
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Robertfausk\Behat\PantherExtension\ServiceContainer\Driver;
5
6
use Behat\MinkExtension\ServiceContainer\Driver\DriverFactory;
7
use Robertfausk\Behat\PantherExtension\ServiceContainer\PantherConfiguration;
8
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
9
use Symfony\Component\DependencyInjection\Definition;
10
11
/**
12
 * @author Robert Freigang <[email protected]>
13
 */
14
class PantherFactory implements DriverFactory
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19 1
    public function getDriverName()
20
    {
21 1
        return 'panther';
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 1
    public function supportsJavascript()
28
    {
29 1
        return true;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function configure(ArrayNodeDefinition $builder)
36
    {
37
        $configuration = new PantherConfiguration();
38
        $builder->append($configuration->addOptionsNode());
39
        $builder->append($configuration->addKernelOptionsNode());
40
        $builder->append($configuration->addManagerOptionsNode());
41
    }
42
43
    /**
44 3
     * {@inheritdoc}
45
     */
46 3
    public function buildDriver(array $config)
47
    {
48
        if (!class_exists('Behat\Mink\Driver\PantherDriver')) {
49
            throw new \RuntimeException(
50
                'Install MinkPantherDriver in order to use panther driver.'
51
            );
52 3
        }
53 3
54
        return new Definition(
55 3
            'Behat\Mink\Driver\PantherDriver',
56
            array(
57
                $config['options'] ?? [],
58
                $config['kernel_options'] ?? [],
59
                $config['manager_options'] ?? [],
60
            )
61
        );
62
    }
63
}
64