Overview

Namespaces

  • Peridot
    • WebDriverManager
      • Binary
        • Decompression
        • Request
      • Console
      • Event
      • OS
      • Process
      • Test
  • PHP

Classes

  • AbstractBinary
  • BinaryResolver
  • ChromeDriver
  • CompressedBinary
  • IEDriver
  • SeleniumStandalone

Interfaces

  • BinaryInterface
  • BinaryResolverInterface
  • DriverInterface
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: namespace Peridot\WebDriverManager\Binary;
 3: 
 4: /**
 5:  * CompressedBinary extends the AbstractBinary to include behavior
 6:  * for handling compressed binaries.
 7:  *
 8:  * @package Peridot\WebDriverManager\Binary
 9:  */
10: abstract class CompressedBinary extends AbstractBinary
11: {
12:     /**
13:      * Overrides default save behavior to first decompress
14:      * an archive format before saving it to a directory.
15:      *
16:      * @param string $directory
17:      * @return bool
18:      */
19:     public function save($directory)
20:     {
21:         if (empty($this->contents)) {
22:             return false;
23:         }
24: 
25:         if ($this->exists($directory)) {
26:             return true;
27:         }
28: 
29:         $compressedPath = $directory . DIRECTORY_SEPARATOR . $this->getOutputFileName();
30:         $this->removeOldVersions($directory);
31:         file_put_contents($compressedPath, $this->contents);
32:         $extracted = $this->resolver->extract($compressedPath, $directory);
33: 
34:         if ($extracted) {
35:             chmod("$directory/{$this->getExtractedName()}", 0777);
36:         }
37: 
38:         return $extracted;
39:     }
40: 
41:     /**
42:      * {@inheritdoc}
43:      *
44:      * @param $directory
45:      * @return bool
46:      */
47:     public function exists($directory)
48:     {
49:         return file_exists("$directory/{$this->getOutputFileName()}");
50:     }
51: 
52:     /**
53:      * Return the output filename for the compressed binary.
54:      *
55:      * @return string
56:      */
57:     abstract public function getOutputFileName();
58: 
59:     /**
60:      * Get the name of the extracted binary.
61:      *
62:      * @return string
63:      */
64:     abstract public function getExtractedName();
65: }
66: 
WebDriver Manager API documentation generated by ApiGen