ShareNotificationsWithView::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 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