Conditions | 4 |
Paths | 4 |
Total Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
22 | public function __invoke(User $currentUser, $employeeId, $weekOf) |
||
23 | { |
||
24 | if (! $currentUser->isAuthenticated()) { |
||
25 | return $this->payload->setStatus(Payload::NOT_AUTHENTICATED); |
||
26 | } |
||
27 | |||
28 | if ($currentUser->getId() !== $employeeId) { |
||
29 | return $this->payload->setStatus(Payload::NOT_AUTHORIZED); |
||
30 | } |
||
31 | |||
32 | try { |
||
33 | $weekOf = new \DateTimeImmutable($weekOf); |
||
34 | } catch (\Exception $e) { |
||
35 | return $this->payload->setStatus(Payload::NOT_VALID) |
||
36 | ->setMessages([ |
||
37 | "date" => self::INVALID_DATE_MESSAGE |
||
38 | ]); |
||
39 | } |
||
40 | |||
41 | $summary = $this->calculator->calculateHoursWorkedInWeek($currentUser, $weekOf); |
||
42 | |||
43 | return $this->payload->setStatus(Payload::SUCCESS) |
||
44 | ->setOutput($summary); |
||
45 | } |
||
46 | } |
||
47 |