Messenger::deliver()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 2
eloc 11
c 4
b 0
f 0
nc 2
nop 0
dl 0
loc 16
rs 9.9
1
<?php namespace GeneaLabs\LaravelMessenger;
2
3
use Illuminate\View\View;
4
5
class Messenger
6
{
7
    public function deliver() : View
8
    {
9
        $message = session('genealabs-laravel-messenger.message');
10
        session()->forget('genealabs-laravel-messenger.message');
11
12
        if (! $message) {
13
            return view("genealabs-laravel-messenger::empty");
14
        }
15
16
        return view("genealabs-laravel-messenger::{$message->framework}.{$message->type}")->with([
0 ignored issues
show
Bug introduced by
The property type does not seem to exist on Illuminate\Session\Store.
Loading history...
Bug introduced by
The property type does not seem to exist on Illuminate\Session\SessionManager.
Loading history...
Bug introduced by
The property framework does not seem to exist on Illuminate\Session\Store.
Loading history...
Bug introduced by
The property framework does not seem to exist on Illuminate\Session\SessionManager.
Loading history...
17
            'autoHide' => $message->autoHide,
0 ignored issues
show
Bug introduced by
The property autoHide does not seem to exist on Illuminate\Session\SessionManager.
Loading history...
Bug introduced by
The property autoHide does not seem to exist on Illuminate\Session\Store.
Loading history...
18
            "id" => $message->id,
0 ignored issues
show
Bug introduced by
The property id is declared protected in Illuminate\Session\Store and cannot be accessed from this context.
Loading history...
Bug introduced by
The property id does not seem to exist on Illuminate\Session\SessionManager.
Loading history...
19
            'message' => $message->message,
0 ignored issues
show
Bug introduced by
The property message does not seem to exist on Illuminate\Session\SessionManager.
Loading history...
Bug introduced by
The property message does not seem to exist on Illuminate\Session\Store.
Loading history...
20
            'level' => $message->level,
0 ignored issues
show
Bug introduced by
The property level does not seem to exist on Illuminate\Session\Store.
Loading history...
Bug introduced by
The property level does not seem to exist on Illuminate\Session\SessionManager.
Loading history...
21
            'section' => $message->section,
0 ignored issues
show
Bug introduced by
The property section does not seem to exist on Illuminate\Session\SessionManager.
Loading history...
Bug introduced by
The property section does not seem to exist on Illuminate\Session\Store.
Loading history...
22
            'title' => $message->title,
0 ignored issues
show
Bug introduced by
The property title does not seem to exist on Illuminate\Session\SessionManager.
Loading history...
Bug introduced by
The property title does not seem to exist on Illuminate\Session\Store.
Loading history...
23
        ]);
24
    }
25
26
    public function send(
27
        string $text,
28
        string $title = null,
29
        string $level = null,
30
        bool $autoHide = null,
31
        string $framework = null,
32
        string $type = null
33
    ) {
34
        $message = new Message([
35
            'message' => $text,
36
            'title' => $title,
37
            'level' => $level,
38
            'autoHide' => $autoHide,
39
            'framework' => $framework,
40
            'type' => $type,
41
        ]);
42
43
        if ($text) {
44
            session(['genealabs-laravel-messenger.message' => $message]);
45
        }
46
    }
47
}
48