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

InvoiceDamageCommandHandler::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
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
}