|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Factory for creating thumbnail instances |
|
5
|
|
|
* |
|
6
|
|
|
* @author Sam Stenvall <[email protected]> |
|
7
|
|
|
* @copyright Copyright © Sam Stenvall 2015- |
|
8
|
|
|
* @license https://www.gnu.org/licenses/gpl.html The GNU General Public License v3.0 |
|
9
|
|
|
*/ |
|
10
|
|
|
class ThumbnailFactory |
|
11
|
|
|
{ |
|
12
|
|
|
|
|
13
|
|
|
const THUMBNAIL_TYPE_ACTOR = 'actor'; |
|
14
|
|
|
const THUMBNAIL_TYPE_SEASON = 'season'; |
|
15
|
|
|
const THUMBNAIL_TYPE_VIDEO = 'video'; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @var string[] list of placeholder images per thumbnail type |
|
19
|
|
|
*/ |
|
20
|
|
|
private static $placeholderPaths = array( |
|
21
|
|
|
self::THUMBNAIL_TYPE_ACTOR => 'images/placeholder-actor.jpg', |
|
22
|
|
|
self::THUMBNAIL_TYPE_SEASON => 'images/placeholder-folder.jpg', |
|
23
|
|
|
self::THUMBNAIL_TYPE_VIDEO => 'images/placeholder-video.jpg' |
|
24
|
|
|
); |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Creates and returns a thumbnail instance |
|
28
|
|
|
* @param string $imagePath the path to the image |
|
29
|
|
|
* @param int $size the desired thumbnail size |
|
30
|
|
|
* @param string $type the thumbnail type |
|
31
|
|
|
* @return AbstractThumbnail |
|
32
|
|
|
*/ |
|
33
|
|
|
public static function create($imagePath, $size, $type = self::THUMBNAIL_TYPE_VIDEO) |
|
34
|
|
|
{ |
|
35
|
|
|
if (self::isPlaceHolderPath($imagePath)) |
|
36
|
|
|
{ |
|
37
|
|
|
$placeholderPath = self::$placeholderPaths[$type]; |
|
38
|
|
|
return new PlaceholderThumbnail($placeholderPath); |
|
39
|
|
|
} |
|
40
|
|
|
else |
|
41
|
|
|
return new Thumbnail($imagePath, $size); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Returns whether the specified path points to a placeholder image. |
|
46
|
|
|
* A placeholder path can either be empty or begin with image://placeholder |
|
47
|
|
|
* @param $path the path to check |
|
|
|
|
|
|
48
|
|
|
* @return bool |
|
49
|
|
|
*/ |
|
50
|
|
|
private static function isPlaceHolderPath($path) |
|
51
|
|
|
{ |
|
52
|
|
|
return empty($path) || |
|
53
|
|
|
substr($path, 0, strlen('image://placeholder')) === 'image://placeholder'; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Prevent construction |
|
58
|
|
|
*/ |
|
59
|
|
|
private function __construct() |
|
60
|
|
|
{ |
|
61
|
|
|
|
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths