CollectionService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 28
ccs 0
cts 15
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fillCollectionDTO() 0 6 1
A getCommand() 0 7 1
1
<?php
2
namespace App\Service;
3
4
use App\Entity\Collection;
5
use App\DTO\CollectionDTO;
6
use App\Command\CommandInterface;
7
use App\Command\CreateCollectionCommand;
8
use App\Command\UpdateCollectionCommand;
9
use Ramsey\Uuid\Uuid;
10
use App\Traits\CommandInstanceTrait;
11
12
class CollectionService
13
{
14
    use CommandInstanceTrait;
15
16
    /**
17
     * @param Collection $collection
18
     * @return CollectionDTO
19
     */
20
    public function fillCollectionDTO(Collection $collection): CollectionDTO
21
    {
22
        return new CollectionDTO(
23
            $collection->getId()->toString(),
24
            $collection->getName(),
25
            $collection->getDescription()
26
        );
27
    }
28
29
    /**
30
     * @param CollectionDTO $collectionDTO
31
     * @return CreateCollectionCommand|UpdateCollectionCommand
32
     */
33
    public function getCommand(CollectionDTO $collectionDTO):  CommandInterface
34
    {
35
        $command = $this->getCommandInstance($collectionDTO->getId(), 'Collection');
36
        return $command->newInstanceArgs([
37
            $collectionDTO->getId() ?? Uuid::uuid4(),
38
            $collectionDTO->getName(),
39
            $collectionDTO->getDescription()
40
        ]);
41
    }
42
}