Passed
Push — master ( 9aef17...9e5266 )
by Gabriel
05:26
created

Collection   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 5
Bugs 0 Features 5
Metric Value
eloc 24
dl 0
loc 91
ccs 28
cts 32
cp 0.875
rs 10
c 5
b 0
f 5
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A __construct() 0 4 1
A hydrateLoader() 0 6 1
A getDefaultConversion() 0 3 1
A hasConversions() 0 3 1
A getOriginalPath() 0 3 1
A setName() 0 4 1
A setOriginalPath() 0 3 1
1
<?php
2
3
namespace ByTIC\MediaLibrary\Collections;
4
5
use ByTIC\MediaLibrary\Collections\UploadStrategy\Traits\HasStrategyTrait;
6
use ByTIC\MediaLibrary\Loaders\AbstractLoader;
7
use ByTIC\MediaLibrary\Media\Media;
8
use ByTIC\MediaLibrary\Validation\Constraints\Traits\HasConstraintTrait;
9
use ByTIC\MediaLibrary\Validation\Traits\HasValidatorTrait;
10
use Nip\Collections\Lazy\AbstractLazyCollection;
11
12
/**
13
 * Class Collection
14
 * @package ByTIC\MediaLibrary\Collections
15
 *
16
 * @method Media get
17
 */
18
class Collection extends AbstractLazyCollection
19
{
20 1
    use Traits\HasAcceptsMediaTrait;
21 1
    use Traits\LoadMediaTrait;
22 1
    use Traits\HasDefaultMediaTrait;
23 1
    use Traits\HasRecordTrait;
24 1
    use Traits\MediaOperationsTraits;
25 1
    use Traits\HasFilesystemTrait;
26 1
    use HasValidatorTrait;
27 1
    use HasStrategyTrait;
28 1
    use HasConstraintTrait;
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 16
    public function __construct($items = [])
34
    {
35 16
        parent::__construct($items);
36 16
        $this->initHasAcceptsMedia();
37 16
    }
38
39
    /**
40
     * @var string
41
     */
42
    protected $name;
43
44
    /**
45
     * @var string
46
     */
47
    protected $originalPath = null;
48
49
    /**
50
     * @return string
51
     */
52 11
    public function getName(): string
53
    {
54 11
        return $this->name;
55
    }
56
57
    /**
58
     * @param string $name
59
     */
60 12
    public function setName(string $name)
61
    {
62 12
        $this->name = $name;
63 12
        $this->setContraintName($name);
64 12
    }
65
66
    /**
67
     * @return string
68
     */
69 2
    public function getOriginalPath()
70
    {
71 2
        return $this->originalPath;
72
    }
73
74
    /**
75
     * @param string $originalPath
76
     */
77 4
    public function setOriginalPath(string $originalPath)
78
    {
79 4
        $this->originalPath = $originalPath;
80 4
    }
81
82
    /**
83
     * @return string
84
     */
85
    protected function getDefaultConversion()
86
    {
87
        return 'default';
88
    }
89
90
    /**
91
     * @return bool
92
     */
93
    protected function hasConversions()
94
    {
95
        return true;
96
    }
97
98
    /**
99
     * @param AbstractLoader $loader
100
     *
101
     * @return AbstractLoader
102
     */
103 7
    protected function hydrateLoader($loader)
104
    {
105 7
        $loader->setCollection($this);
106 7
        $loader->setFilesystem($this->getFilesystem());
107
108 7
        return $loader;
109
    }
110
}
111