SeleniumStandalone   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 1
dl 0
loc 68
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getName() 0 4 1
A getFileName() 0 5 1
A getUrl() 0 6 1
A removeOldVersions() 0 7 2
A getOldFilePattern() 0 4 1
1
<?php
2
namespace Peridot\WebDriverManager\Binary;
3
4
use Peridot\WebDriverManager\Versions;
5
6
/**
7
 * SeleniumStandalone is responsible for resolving Selenium Server itself.
8
 *
9
 * @package Peridot\WebDriverManager\Binary
10
 */
11
class SeleniumStandalone extends AbstractBinary
12
{
13
    /**
14
     * @param BinaryResolverInterface $resolver
15
     */
16
    public function __construct(BinaryResolverInterface $resolver)
17
    {
18
        parent::__construct($resolver);
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     *
24
     * @return string
25
     */
26
    public function getName()
27
    {
28
        return 'selenium';
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     *
34
     * @return string
35
     */
36
    public function getFileName()
37
    {
38
        $version = Versions::SELENIUM;
39
        return "selenium-server-standalone-$version.jar";
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     *
45
     * @return string
46
     */
47
    public function getUrl()
48
    {
49
        $version = Versions::SELENIUM;
50
        $short = substr($version, 0, strrpos($version, '.'));
51
        return "http://selenium-release.storage.googleapis.com/$short/{$this->getFileName()}";
52
    }
53
54
    /**
55
     * Remove old versions of the binary.
56
     *
57
     * @param $directory
58
     * @return void
59
     */
60
    protected function removeOldVersions($directory)
61
    {
62
        $paths = glob("$directory/selenium-server-standalone-*");
63
        foreach ($paths as $path) {
64
            unlink($path);
65
        }
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     *
71
     * @param string $directory
72
     * @return string
73
     */
74
    protected function getOldFilePattern($directory)
75
    {
76
        return $directory . '/' . str_replace(Versions::SELENIUM, '*', $this->getFileName());
77
    }
78
}
79