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: