SymfonyDriverFactory::supportsJavascript()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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