Completed
Push — 2.0 ( 663717...809d1e )
by Nicolas
15:54
created

ThumbnailManagerRepository   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A registerThumbnail() 0 4 1
A all() 0 4 1
A find() 0 10 3
1
<?php
2
3
namespace Modules\Media\Image;
4
5
class ThumbnailManagerRepository implements ThumbnailManager
6
{
7
    /**
8
     * @var array
9
     */
10
    private $thumbnails = [];
11
12
    public function registerThumbnail($name, array $filters)
13
    {
14
        $this->thumbnails[] = Thumbnail::make([$name => $filters]);
15
    }
16
17
    /**
18
     * Return all registered thumbnails
19
     * @return array
20
     */
21
    public function all()
22
    {
23
        return $this->thumbnails;
24
    }
25
26
    /**
27
     * Find the filters for the given thumbnail
28
     * @param $thumbnail
29
     * @return array
30
     */
31
    public function find($thumbnail)
32
    {
33
        foreach ($this->all() as $thumb) {
34
            if ($thumb->name() === $thumbnail) {
35
                return $thumb->filters();
36
            }
37
        }
38
39
        return [];
40
    }
41
}
42