1 | <?php |
||
13 | class Local implements ImageDriverInterface |
||
14 | { |
||
15 | const DEFAULT_DIRECTORY = 'behat-screenshot'; |
||
16 | const CONFIG_PARAM_SCREENSHOT_DIRECTORY = 'screenshot_directory'; |
||
17 | const CONFIG_PARAM_CLEAR_SCREENSHOT_DIRECTORY = 'clear_screenshot_directory'; |
||
18 | |||
19 | /** |
||
20 | * @var Filesystem |
||
21 | */ |
||
22 | private $filesystem; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | private $screenshotDirectory; |
||
28 | |||
29 | /** |
||
30 | * @var Finder |
||
31 | */ |
||
32 | private $finder; |
||
33 | |||
34 | /** |
||
35 | * @var \finfo |
||
36 | */ |
||
37 | private $fileInfo; |
||
38 | |||
39 | /** |
||
40 | * @param Filesystem $filesystem |
||
41 | * @param Finder $finder |
||
42 | * @param \finfo $fileInfo |
||
43 | */ |
||
44 | public function __construct(Filesystem $filesystem = null, Finder $finder = null, \finfo $fileInfo = null) |
||
50 | |||
51 | /** |
||
52 | * @param ArrayNodeDefinition $builder |
||
53 | */ |
||
54 | public function configure(ArrayNodeDefinition $builder) |
||
66 | |||
67 | /** |
||
68 | * @param ContainerBuilder $container |
||
69 | * @param array $config |
||
70 | */ |
||
71 | public function load(ContainerBuilder $container, array $config) |
||
79 | |||
80 | /** |
||
81 | * @param string $binaryImage |
||
82 | * @param string $filename |
||
83 | * |
||
84 | * @return string URL to the image |
||
85 | */ |
||
86 | public function upload($binaryImage, $filename) |
||
94 | |||
95 | /** |
||
96 | * @return string |
||
97 | */ |
||
98 | private function getDefaultDirectory() |
||
102 | |||
103 | /** |
||
104 | * @param string $fileName |
||
105 | * |
||
106 | * @return string |
||
107 | */ |
||
108 | private function getTargetPath($fileName) |
||
113 | |||
114 | /** |
||
115 | * @param string $directory |
||
116 | * |
||
117 | * @throws IOException |
||
118 | */ |
||
119 | private function ensureDirectoryExists($directory) |
||
129 | |||
130 | private function clearScreenshotDirectory() |
||
143 | } |