MediaGroupDataTransferObject   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 39
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMediaGroupEntity() 0 3 1
A hasExistingMediaGroup() 0 3 1
A __construct() 0 7 2
1
<?php
2
3
namespace Backend\Modules\MediaLibrary\Domain\MediaGroup;
4
5
use Ramsey\Uuid\Uuid;
6
7
class MediaGroupDataTransferObject
8
{
9
    /** @var MediaGroup */
10
    private $mediaGroupEntity;
11
12
    /**
13
     * You can give an id
14
     *
15
     * @var Uuid|null
16
     */
17
    public $id;
18
19
    /** @var Type */
20
    public $type;
21
22
    /** @var array */
23
    public $mediaItemIdsToConnect;
24
25
    /** @var bool */
26
    public $removeAllPreviousConnectedMediaItems = true;
27
28
    public function __construct(MediaGroup $mediaGroup = null)
29
    {
30
        $this->mediaGroupEntity = $mediaGroup;
31
32
        if ($this->hasExistingMediaGroup()) {
33
            $this->id = $this->mediaGroupEntity->getId();
34
            $this->type = $this->mediaGroupEntity->getType();
35
        }
36
    }
37
38
    public function getMediaGroupEntity(): MediaGroup
39
    {
40
        return $this->mediaGroupEntity;
41
    }
42
43
    public function hasExistingMediaGroup(): bool
44
    {
45
        return $this->mediaGroupEntity instanceof MediaGroup;
46
    }
47
}
48