Issues (61)

src/Helpers/ThumbHelper.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Itstructure\MFU\Helpers;
4
5
use Exception;
6
use Imagine\Image\ImageInterface;
0 ignored issues
show
The type Imagine\Image\ImageInterface was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Itstructure\MFU\Classes\ThumbConfig;
8
9
class ThumbHelper
10
{
11
    public static function configureThumb(string $alias, array $config): ThumbConfig
12
    {
13
        if (!isset($config['name']) ||
14
            !isset($config['size']) ||
15
            !is_array($config['size']) ||
16
            (!isset($config['size'][0]) && !is_null($config['size'][0])) ||
17
            (!isset($config['size'][1]) && !is_null($config['size'][1]))
18
        ) {
19
            throw new Exception('Error in thumb configuration.');
20
        }
21
22
        return new ThumbConfig(
23
            $alias,
24
            $config['name'],
25
            $config['size'][0],
26
            $config['size'][1],
27
            !empty($config['mode']) ? $config['mode'] : ImageInterface::THUMBNAIL_OUTBOUND
28
        );
29
    }
30
31
    public static function getDefaultSizes(): array
32
    {
33
        return [
34
            'name' => 'Default size',
35
            'size' => [150, 150],
36
        ];
37
    }
38
}