SymfonyDriverFactory   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 40
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getDriverName() 0 4 1
A supportsJavascript() 0 4 1
A configure() 0 3 1
A buildDriver() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FriendsOfBehat\SymfonyExtension\Driver\Factory;
6
7
use Behat\Mink\Driver\BrowserKitDriver;
8
use Behat\MinkExtension\ServiceContainer\Driver\DriverFactory;
9
use FriendsOfBehat\SymfonyExtension\Driver\SymfonyDriver;
10
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
11
use Symfony\Component\DependencyInjection\Definition;
12
use Symfony\Component\DependencyInjection\Reference;
13
14
final class SymfonyDriverFactory implements DriverFactory
15
{
16
    /** @var string */
17
    private $name;
18
19
    /** @var Reference */
20
    private $kernel;
21
22
    public function __construct(string $name, Reference $kernel)
23
    {
24
        $this->name = $name;
25
        $this->kernel = $kernel;
26
    }
27
28
    public function getDriverName(): string
29
    {
30
        return $this->name;
31
    }
32
33
    public function supportsJavascript(): bool
34
    {
35
        return false;
36
    }
37
38
    public function configure(ArrayNodeDefinition $builder): void
39
    {
40
    }
41
42
    public function buildDriver(array $config): Definition
43
    {
44
        if (!class_exists(BrowserKitDriver::class)) {
45
            throw new \RuntimeException('Install "friends-of-behat/mink-browserkit-driver" (drop-in replacement for "behat/mink-browserkit-driver") in order to use the "symfony" driver.');
46
        }
47
48
        return new Definition(SymfonyDriver::class, [
49
            $this->kernel,
50
            '%mink.base_url%',
51
        ]);
52
    }
53
}
54