Completed
Push — feature/fixing_cost ( 2c76a0...f58af6 )
by Laurent
01:38
created

InvoiceDamageCommandHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 5 1
1
<?php
2
3
4
namespace FlightLog\Application\Damage\Command;
5
6
7
use FlightLog\Domain\Damage\DamageId;
8
use FlightLog\Infrastructure\Damage\Repository\FlightDamageRepository;
9
10
final class InvoiceDamageCommandHandler
11
{
12
13
    /**
14
     * @var FlightDamageRepository
15
     */
16
    private $damageRepository;
17
18
    /**
19
     * @param FlightDamageRepository $damageRepository
20
     */
21
    public function __construct(FlightDamageRepository $damageRepository)
22
    {
23
        $this->damageRepository = $damageRepository;
24
    }
25
26
    /**
27
     * @param InvoiceDamageCommand $command
28
     *
29
     * @throws \Exception
30
     */
31
    public function __invoke(InvoiceDamageCommand $command){
32
        $damage = $this->damageRepository->getById(DamageId::create($command->getDamageId()));
33
        $damage = $damage->invoice();
34
        $this->damageRepository->save($damage);
35
    }
36
37
38
}