PantherFactory   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
wmc 5
eloc 16
c 0
b 0
f 0
dl 0
loc 46
ccs 9
cts 15
cp 0.6
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A supportsJavascript() 0 3 1
A getDriverName() 0 3 1
A buildDriver() 0 14 2
A configure() 0 6 1
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