Messenger   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 6
Bugs 0 Features 0
Metric Value
eloc 21
c 6
b 0
f 0
dl 0
loc 40
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 19 2
A deliver() 0 16 2
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