| Total Complexity | 6 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class NotificationManager implements NotificationManagerInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var NotificationRepository |
||
| 14 | */ |
||
| 15 | private $repository; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var NotificationFactoryInterface |
||
| 19 | */ |
||
| 20 | private $factory; |
||
| 21 | |||
| 22 | public function __construct(NotificationFactoryInterface $factory, NotificationRepository $repository) |
||
| 23 | { |
||
| 24 | $this->repository = $repository; |
||
| 25 | $this->factory = $factory; |
||
| 26 | } |
||
| 27 | |||
| 28 | public function get(int $id): Notification |
||
| 29 | { |
||
| 30 | $notification = $this->repository->find($id); |
||
| 31 | |||
| 32 | if (!$notification instanceof Notification) { |
||
| 33 | throw new NotFoundHttpException(); |
||
| 34 | } |
||
| 35 | |||
| 36 | return $notification; |
||
| 37 | } |
||
| 38 | |||
| 39 | public function create(string $title, string $content, string $ownerId = null): Notification |
||
| 40 | { |
||
| 41 | $notification = $this->factory->create($title, $content, $ownerId); |
||
| 42 | $this->save($notification); |
||
| 43 | |||
| 44 | return $notification; |
||
| 45 | } |
||
| 46 | |||
| 47 | public function markAsRead(Notification $notification): void |
||
| 51 | } |
||
| 52 | |||
| 53 | public function save(Notification $notification): void |
||
| 54 | { |
||
| 58 |