ChromeProvider::serverUrl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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