| Total Complexity | 8 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 78.95% |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | class NotificationService implements NotificationServiceContract |
||
| 17 | { |
||
| 18 | protected $user; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * NotificationService constructor. |
||
| 22 | * |
||
| 23 | * @param $service |
||
| 24 | */ |
||
| 25 | 3 | public function __construct(UserServiceContract $service) |
|
| 28 | 3 | } |
|
| 29 | |||
| 30 | 2 | public function find($id): ?Notification |
|
| 31 | { |
||
| 32 | 2 | if ($id instanceof Notification) { |
|
| 33 | return $id; |
||
| 34 | } |
||
| 35 | |||
| 36 | 2 | $notification = Notification::find($id); |
|
| 37 | |||
| 38 | 2 | if ($notification === null) { |
|
| 39 | throw new NotFoundHttpException(); |
||
| 40 | } |
||
| 41 | |||
| 42 | 2 | return $notification; |
|
| 43 | } |
||
| 44 | |||
| 45 | 1 | public function allNotificationsByUser($user) |
|
| 46 | { |
||
| 47 | 1 | return $this->user->find($user)->notifications; |
|
|
|
|||
| 48 | } |
||
| 49 | |||
| 50 | 1 | public function unreadNotifcationsByUser($user) |
|
| 51 | { |
||
| 52 | 1 | return $this->user->find($user)->unreadNotifications; |
|
| 53 | } |
||
| 54 | |||
| 55 | 2 | public function markAsRead($id) |
|
| 58 | 2 | } |
|
| 59 | |||
| 60 | public function markAsUnread($id) |
||
| 63 | } |
||
| 64 | } |
||
| 65 |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.