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

ThumbnailManagerRepository::all()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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