ChromeProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 47
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 11 1
A configure() 0 2 1
A serverUrl() 0 3 1
1
<?php
2
3
namespace Bavix\Cases\Provider;
4
5
use Facebook\WebDriver\Chrome\ChromeOptions;
6
use Facebook\WebDriver\Remote\DesiredCapabilities;
7
use Bavix\Cases\Provider;
8
use Bavix\Cases\Params;
9
use Bavix\Cases\RemoteWebDriver;
10
11
class ChromeProvider implements Provider
12
{
13
14
    /**
15
     * @var Params
16
     */
17
    protected $params;
18
19
    /**
20
     * ChromeCap constructor.
21
     * @param Params $params
22
     */
23
    public function __construct(Params $params)
24
    {
25
        $this->params = $params;
26
    }
27
28
    /**
29
     * @return DesiredCapabilities
30
     */
31
    public function handle(): DesiredCapabilities
32
    {
33
        $options = new ChromeOptions();
34
        $options->addArguments([
35
            \sprintf('--window-size=%d,%d', $this->params->getWidth(), $this->params->getHeight())
36
        ]);
37
38
        $caps = DesiredCapabilities::chrome();
39
        $caps->setCapability(ChromeOptions::CAPABILITY, $options);
40
41
        return $caps;
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function serverUrl(): string
48
    {
49
        return $_ENV['CHROME_URL'];
50
    }
51
52
    /**
53
     * @param RemoteWebDriver $driver
54
     * @return void
55
     */
56
    public function configure(RemoteWebDriver $driver)
57
    {
58
59
    }
60
61
}
62