ShareNotificationsWithView   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 37
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 7 1
1
<?php
2
3
namespace Rojtjo\Notifier\Laravel;
4
5
use Closure;
6
use Illuminate\Contracts\View\Factory;
7
use Illuminate\Http\Request;
8
use Rojtjo\Notifier\Notifier;
9
10
class ShareNotificationsWithView
11
{
12
    /**
13
     * @var Notifier
14
     */
15
    private $notifier;
16
17
    /**
18
     * @var Factory
19
     */
20
    private $viewFactory;
21
22
    /**
23
     * @param Notifier $notifier
24
     * @param Factory $viewFactory
25
     */
26 3
    public function __construct(Notifier $notifier, Factory $viewFactory)
27
    {
28 3
        $this->notifier = $notifier;
29 3
        $this->viewFactory = $viewFactory;
30 3
    }
31
32
    /**
33
     * Handle an incoming request.
34
     *
35
     * @param Request $request
36
     * @param Closure $next
37
     * @return mixed
38
     */
39 3
    public function handle($request, Closure $next)
40
    {
41 3
        $notifications = $this->notifier->getCurrentNotifications();
42 3
        $this->viewFactory->share('notifications', $notifications);
43
44 3
        return $next($request);
45
    }
46
}
47