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

ThumbnailManagerRepository::find()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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