AddCarCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 16 1
A __construct() 0 5 1
1
<?php
2
3
namespace Madkom\RegistryApplication\Application\CarManagement\Command\Car;
4
5
use Madkom\RegistryApplication\Application\CarManagement\CarDTO;
6
use Madkom\RegistryApplication\Application\CarManagement\Command\CommandInterface;
7
use Madkom\RegistryApplication\Domain\CarManagement\Car;
8
use Madkom\RegistryApplication\Domain\CarManagement\CarRepositoryInterface;
9
10
class AddCarCommand implements CommandInterface
11
{
12
    private $preparedCar;
13
    private $carRepository;
14
15
    public function __construct(CarRepositoryInterface $carRepository, CarDTO $preparedCar)
16
    {
17
        $this->preparedCar = $preparedCar;
18
        $this->carRepository = $carRepository;
19
    }
20
21
    public function execute()
22
    {
23
        $car = Car::createCustom(
24
            $this->preparedCar->id,
25
            $this->preparedCar->responsiblePerson,
26
            $this->preparedCar->model,
27
            $this->preparedCar->brand,
28
            $this->preparedCar->registrationNumber,
29
            $this->preparedCar->productionDate,
30
            $this->preparedCar->warrantyPeriod,
31
            $this->preparedCar->city,
32
            $this->preparedCar->department
33
        );
34
35
        $this->carRepository->add($car);
36
    }
37
}
38