Completed
Pull Request — master (#339)
by Robert
07:40
created

PantherFactory   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 4
dl 0
loc 55
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDriverName() 0 4 1
A supportsJavascript() 0 4 1
A configure() 0 14 1
A buildDriver() 0 15 2
1
<?php
2
3
/*
4
 * This file is part of the Behat MinkExtension.
5
 * (c) Konstantin Kudryashov <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Behat\MinkExtension\ServiceContainer\Driver;
12
13
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
14
use Symfony\Component\DependencyInjection\Definition;
15
16
/**
17
 * @author Robert Freigang <[email protected]>
18
 */
19
class PantherFactory implements DriverFactory
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function getDriverName()
25
    {
26
        return 'panther';
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function supportsJavascript()
33
    {
34
        return true;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function configure(ArrayNodeDefinition $builder)
41
    {
42
        $builder
43
            ->children()
44
                ->arrayNode('options')
45
                    ->useAttributeAsKey('key')
46
                    ->prototype('variable')->end()
47
                    ->info(
48
                        "These are the options passed as first argument to PantherTestcaseTrait::createPantherClient client constructor."
49
                    )
50
                ->end()
51
            ->end()
52
        ;
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function buildDriver(array $config)
59
    {
60
        if (!class_exists('Behat\Mink\Driver\PantherDriver')) {
61
            throw new \RuntimeException(
62
                'Install MinkPantherDriver in order to use panther driver.'
63
            );
64
        }
65
66
        return new Definition(
67
            'Behat\Mink\Driver\PantherDriver',
68
            array(
69
                $config['options']
70
            )
71
        );
72
    }
73
}
74