1 | <?php namespace Modules\Media\Image; |
||
10 | class Imagy |
||
11 | { |
||
12 | /** |
||
13 | * @var \Intervention\Image\Image |
||
14 | */ |
||
15 | private $image; |
||
16 | /** |
||
17 | * @var ImageFactoryInterface |
||
18 | */ |
||
19 | private $imageFactory; |
||
20 | /** |
||
21 | * @var ThumbnailsManager |
||
22 | */ |
||
23 | private $manager; |
||
24 | |||
25 | /** |
||
26 | * All the different images types where thumbnails should be created |
||
27 | * @var array |
||
28 | */ |
||
29 | private $imageExtensions = ['jpg', 'png', 'jpeg', 'gif']; |
||
30 | /** |
||
31 | * @var Factory |
||
32 | */ |
||
33 | private $filesystem; |
||
34 | |||
35 | /** |
||
36 | * @param ImageFactoryInterface $imageFactory |
||
37 | * @param ThumbnailsManager $manager |
||
38 | */ |
||
39 | public function __construct(ImageFactoryInterface $imageFactory, ThumbnailsManager $manager) |
||
46 | |||
47 | /** |
||
48 | * Get an image in the given thumbnail options |
||
49 | * @param string $path |
||
50 | * @param string $thumbnail |
||
51 | * @param bool $forceCreate |
||
52 | * @return string |
||
53 | */ |
||
54 | public function get($path, $thumbnail, $forceCreate = false) |
||
74 | |||
75 | /** |
||
76 | * Return the thumbnail path |
||
77 | * @param string $originalImage |
||
78 | * @param string $thumbnail |
||
79 | * @return string |
||
80 | */ |
||
81 | public function getThumbnail($originalImage, $thumbnail) |
||
91 | |||
92 | /** |
||
93 | * Create all thumbnails for the given image path |
||
94 | * @param MediaPath $path |
||
95 | */ |
||
96 | public function createAll(MediaPath $path) |
||
112 | |||
113 | /** |
||
114 | * Prepend the thumbnail name to filename |
||
115 | * @param $path |
||
116 | * @param $thumbnail |
||
117 | * @return mixed|string |
||
118 | */ |
||
119 | private function newFilename($path, $thumbnail) |
||
120 | { |
||
121 | $filename = pathinfo($path, PATHINFO_FILENAME); |
||
122 | |||
123 | return $filename . '_' . $thumbnail . '.' . pathinfo($path, PATHINFO_EXTENSION); |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * Return the already created file if it exists and force create is false |
||
128 | * @param string $filename |
||
129 | * @param bool $forceCreate |
||
130 | * @return bool |
||
131 | */ |
||
132 | private function returnCreatedFile($filename, $forceCreate) |
||
136 | |||
137 | /** |
||
138 | * Write the given image |
||
139 | * @param string $filename |
||
140 | * @param Stream $image |
||
141 | */ |
||
142 | private function writeImage($filename, Stream $image) |
||
155 | |||
156 | /** |
||
157 | * Make a new image |
||
158 | * @param MediaPath $path |
||
159 | * @param string $filename |
||
160 | * @param string null $thumbnail |
||
161 | */ |
||
162 | private function makeNew(MediaPath $path, $filename, $thumbnail) |
||
173 | |||
174 | /** |
||
175 | * Check if the given path is en image |
||
176 | * @param string $path |
||
177 | * @return bool |
||
178 | */ |
||
179 | public function isImage($path) |
||
180 | { |
||
181 | return in_array(pathinfo($path, PATHINFO_EXTENSION), $this->imageExtensions); |
||
182 | } |
||
183 | |||
184 | /** |
||
185 | * Delete all files on disk for the given file in storage |
||
186 | * This means the original and the thumbnails |
||
187 | * @param $file |
||
188 | * @return bool |
||
189 | */ |
||
190 | public function deleteAllFor(File $file) |
||
208 | |||
209 | private function getConfiguredFilesystem() |
||
213 | |||
214 | /** |
||
215 | * @param $filename |
||
216 | * @return bool |
||
217 | */ |
||
218 | private function fileExists($filename) |
||
222 | |||
223 | /** |
||
224 | * @param string $path |
||
225 | * @return string |
||
226 | */ |
||
227 | private function getDestinationPath($path) |
||
235 | } |
||
236 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: