Passed
Push — master ( 0c5e09...b94ee9 )
by Arthur
08:40 queued 02:13
created

NotificationController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 17
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 3 1
A allUnread() 0 3 1
A read() 0 5 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 14.10.18
6
 * Time: 18:58
7
 */
8
9
namespace Foundation\Controllers;
10
11
use Foundation\Resources\NotificationResource;
12
use Illuminate\Routing\Controller;
13
14
class NotificationController extends Controller
15
{
16 1
    public function all()
17
    {
18 1
        return NotificationResource::collection(get_authenticated_user()->notifications);
0 ignored issues
show
Bug introduced by
Accessing notifications on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
19
    }
20
21 1
    public function allUnread()
22
    {
23 1
        return NotificationResource::collection(get_authenticated_user()->unreadNotifications);
0 ignored issues
show
Bug introduced by
Accessing unreadNotifications on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
24
    }
25
26 2
    public function read($id)
27
    {
28 2
        get_authenticated_user()->unreadNotifications()->find($id)->markAsRead();
29 2
        return response()->json([
30 2
            "success"
31
        ]);
32
    }
33
}
34