Total Complexity | 5 |
Total Lines | 29 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class SaleCloseAction |
||
11 | { |
||
12 | /** |
||
13 | * @var SaleRepository |
||
14 | */ |
||
15 | private $repo; |
||
16 | |||
17 | public function __construct(SaleRepository $repo) |
||
18 | { |
||
19 | $this->repo = $repo; |
||
20 | } |
||
21 | |||
22 | public function __invoke(SaleCloseCommand $command): Sale |
||
23 | { |
||
24 | $this->checkRequiredInput($command); |
||
25 | $plan = new Plan($command->plan_id, null); |
||
26 | $sale = new Sale(null, $command->target, $command->customer, $plan, $command->time); |
||
27 | $this->repo->delete($sale); |
||
28 | |||
29 | return $sale; |
||
30 | } |
||
31 | |||
32 | protected function checkRequiredInput(SaleCloseCommand $command) |
||
39 | } |
||
40 | } |
||
41 | } |
||
42 |