Completed
Push — master ( 1bbe94...5b57d0 )
by Robert
09:18 queued 07:37
created

PantherFactory::buildDriver()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 12
ccs 0
cts 11
cp 0
crap 6
rs 10
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
    public function getDriverName()
20
    {
21
        return 'panther';
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function supportsJavascript()
28
    {
29
        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
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function buildDriver(array $config)
45
    {
46
        if (!class_exists('Behat\Mink\Driver\PantherDriver')) {
47
            throw new \RuntimeException(
48
                'Install MinkPantherDriver in order to use panther driver.'
49
            );
50
        }
51
52
        return new Definition(
53
            'Behat\Mink\Driver\PantherDriver',
54
            array(
55
                $config['options'] ?? [],
56
            )
57
        );
58
    }
59
}
60