ThumbnailsManager   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 53
rs 10
c 2
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A all() 0 12 3
A find() 0 10 3
1
<?php namespace Modules\Media\Image;
2
3
use Illuminate\Contracts\Config\Repository;
4
5
class ThumbnailsManager
6
{
7
    /**
8
     * @var Module
9
     */
10
    private $module;
11
    /**
12
     * @var Repository
13
     */
14
    private $config;
15
16
    /**
17
     * @param Repository $config
18
     */
19
    public function __construct(Repository $config)
20
    {
21
        $this->module = app('modules');
22
        $this->config = $config;
23
    }
24
25
    /**
26
     * Return all thumbnails for all modules
27
     * @return array
28
     */
29
    public function all()
30
    {
31
        $thumbnails = [];
32
        foreach ($this->module->enabled() as $enabledModule) {
33
            $configuration = $this->config->get(strtolower('asgard.' . $enabledModule->getName()) . '.thumbnails');
34
            if (!is_null($configuration)) {
35
                $thumbnails = array_merge($thumbnails, Thumbnail::makeMultiple($configuration));
36
            }
37
        }
38
39
        return $thumbnails;
40
    }
41
42
    /**
43
     * Find the filters for the given thumbnail
44
     * @param $thumbnail
45
     * @return array
46
     */
47
    public function find($thumbnail)
48
    {
49
        foreach ($this->all() as $thumb) {
50
            if ($thumb->name() == $thumbnail) {
51
                return $thumb->filters();
52
            }
53
        }
54
55
        return [];
56
    }
57
}
58