| Total Complexity | 7 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | class CustomerLoader implements Middleware |
||
| 19 | { |
||
| 20 | private $repo; |
||
| 21 | |||
| 22 | private $user; |
||
| 23 | |||
| 24 | public function __construct(User $user, CustomerRepository $repo) |
||
| 25 | { |
||
| 26 | $this->user = $user; |
||
| 27 | $this->repo = $repo; |
||
| 28 | } |
||
| 29 | |||
| 30 | public function execute($command, callable $next) |
||
| 31 | { |
||
| 32 | if (empty($command->customer)) { |
||
| 33 | $command->customer = $this->findCustomer($command); |
||
| 34 | } |
||
| 35 | |||
| 36 | return $next($command); |
||
| 37 | } |
||
| 38 | |||
| 39 | private function findCustomer($command): Customer |
||
| 51 | } |
||
| 52 | |||
| 53 | private function getCurrentCustomer(): Customer |
||
| 56 | } |
||
| 57 | } |
||
| 58 |