ZombieFactory   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDriverName() 0 4 1
A supportsJavascript() 0 4 1
A configure() 0 13 1
A buildDriver() 0 19 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
class ZombieFactory implements DriverFactory
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function getDriverName()
22
    {
23
        return 'zombie';
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function supportsJavascript()
30
    {
31
        return true;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function configure(ArrayNodeDefinition $builder)
38
    {
39
        $builder
40
            ->children()
41
                ->scalarNode('host')->defaultValue('127.0.0.1')->end()
42
                ->scalarNode('port')->defaultValue(8124)->end()
43
                ->scalarNode('node_bin')->defaultValue('node')->end()
44
                ->scalarNode('server_path')->defaultNull()->end()
45
                ->scalarNode('threshold')->defaultValue(2000000)->end()
46
                ->scalarNode('node_modules_path')->defaultValue('')->end()
47
            ->end()
48
        ;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function buildDriver(array $config)
55
    {
56
        if (!class_exists('Behat\Mink\Driver\ZombieDriver')) {
57
            throw new \RuntimeException(
58
                'Install MinkZombieDriver in order to use zombie driver.'
59
            );
60
        }
61
62
        return new Definition('Behat\Mink\Driver\ZombieDriver', array(
63
            new Definition('Behat\Mink\Driver\NodeJS\Server\ZombieServer', array(
64
                $config['host'],
65
                $config['port'],
66
                $config['node_bin'],
67
                $config['server_path'],
68
                $config['threshold'],
69
                $config['node_modules_path'],
70
            )),
71
        ));
72
    }
73
}
74