1 | <?php |
||
10 | class ImageGenerator |
||
11 | { |
||
12 | /** |
||
13 | * @var Server |
||
14 | */ |
||
15 | private $server; |
||
16 | |||
17 | /** |
||
18 | * @var FilenameGeneratorInterface |
||
19 | */ |
||
20 | private $filenameGenerator; |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | private $defaultImageParameters; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | private $tmpPath; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | private $tmpPrefix; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | private $fallbackImage; |
||
41 | |||
42 | /** |
||
43 | * @param Server $server |
||
44 | * @param FilenameGeneratorInterface $filenameGenerator |
||
45 | * @param array $defaultImageParameters |
||
46 | * @param null $fallbackImage |
||
47 | * @param null $tmpPath |
||
48 | * @param null $tmpPrefix |
||
49 | */ |
||
50 | 6 | public function __construct( |
|
65 | |||
66 | /** |
||
67 | * @param MediaInterface $media |
||
68 | * @param ParameterBag $parameterBag |
||
69 | * @return mixed |
||
70 | */ |
||
71 | 5 | public function generate(MediaInterface $media, ParameterBag $parameterBag) |
|
83 | |||
84 | /** |
||
85 | * @param MediaInterface $media |
||
86 | * @param ParameterBag $parameterBag |
||
87 | * @param $filename |
||
88 | * @throws FilesystemException |
||
89 | * @throws \Exception |
||
90 | */ |
||
91 | 4 | protected function generateImage(MediaInterface $media, ParameterBag $parameterBag, $filename) |
|
112 | |||
113 | /** |
||
114 | * @param MediaInterface $media |
||
115 | * @return string |
||
116 | * @throws FilesystemException |
||
117 | */ |
||
118 | 4 | protected function getImageData(MediaInterface $media) |
|
119 | { |
||
120 | 4 | if ($this->server->getSource()->has($media->getImage())) { |
|
121 | 3 | return $this->server->getSource()->read($media->getImage()); |
|
122 | } |
||
123 | |||
124 | 1 | if (!is_null($this->fallbackImage)) { |
|
125 | return file_get_contents($this->fallbackImage); |
||
126 | } |
||
127 | |||
128 | 1 | throw new FilesystemException('File not found'); |
|
129 | } |
||
130 | |||
131 | /** |
||
132 | * @param MediaInterface $media |
||
133 | * @param string $tmp |
||
134 | * @param ParameterBag $parameterBag |
||
135 | * @return string |
||
136 | */ |
||
137 | 3 | protected function doGenerateImage(MediaInterface $media, $tmp, ParameterBag $parameterBag) |
|
145 | |||
146 | /** |
||
147 | * @return string |
||
148 | */ |
||
149 | 4 | protected function getTemporaryFile() |
|
160 | |||
161 | /** |
||
162 | * @return Server |
||
163 | */ |
||
164 | 1 | public function getServer() |
|
168 | |||
169 | /** |
||
170 | * @return FilenameGeneratorInterface |
||
171 | */ |
||
172 | 1 | public function getFilenameGenerator() |
|
176 | |||
177 | /** |
||
178 | * @return array |
||
179 | */ |
||
180 | 1 | public function getDefaultImageParameters() |
|
184 | |||
185 | /** |
||
186 | * @return string |
||
187 | */ |
||
188 | 1 | public function getTmpPath() |
|
192 | |||
193 | /** |
||
194 | * @return string |
||
195 | */ |
||
196 | 1 | public function getTmpPrefix() |
|
200 | |||
201 | /** |
||
202 | * @return string |
||
203 | */ |
||
204 | 1 | public function getFallbackImage() |
|
208 | } |
||
209 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.