NotificationFeedbackController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A readAction() 0 24 2
1
<?php
2
3
namespace IrishDan\NotificationBundle\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
use Symfony\Component\HttpFoundation\JsonResponse;
7
8
class NotificationFeedbackController extends Controller
9
{
10
    /**
11
     * Route for setting a notification as read
12
     */
13
    public function readAction($uuid)
14
    {
15
        $databaseNotificationManager = $this->get('notification.database_notification_manager');
16
17
        try {
18
            $databaseNotificationManager->findAndSetAsRead(['uuid' => $uuid]);
19
20
            $code = 200;
21
            $status = 'ok';
22
            $message = sprintf('Database notification %s marked as read', $uuid);
23
        } catch (\Exception $e) {
24
            $code = 500;
25
            $status = 'error';
26
            $message = $e->getMessage();
27
        }
28
29
        return new JsonResponse(
30
            [
31
                'status' => $status,
32
                'message' => $message,
33
            ],
34
            $code
35
        );
36
    }
37
}
38