FlashNotifier   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 44
rs 10
wmc 7
lcom 1
cbo 1

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A success() 0 4 1
A error() 0 4 1
A warning() 0 4 1
A info() 0 3 1
A modal() 0 7 1
A message() 0 6 1
1
<?php
2
namespace GeekGhc\LaraFlash;
3
4
class FlashNotifier
5
{
6
    private $session;
7
8
    function __construct(SessionStore $session)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
9
    {
10
        $this->session = $session;
11
    }
12
13
    public function success($message)
14
    {
15
        return $this->message($message,'success');
16
    }
17
18
    public function error($message)
19
    {
20
        return $this->message($message,'error');
21
    }
22
23
    public function warning($message)
24
    {
25
        return $this->message($message,'warning');
26
    }
27
28
    public function info($message){
29
        return $this->message($message,'info');
30
    }
31
32
    public function modal($message, $title = 'Message', $type = 'info')
33
    {
34
        $this->message($message, $type);
35
        $this->session->flash('flash_notification.modal', true);
0 ignored issues
show
Documentation introduced by
true is of type boolean, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
36
        $this->session->flash('flash_notification.title', $title);
0 ignored issues
show
Documentation introduced by
$title is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
37
        return $this;
38
    }
39
40
    public function message($message,$type = 'info')
41
    {
42
        $this->session->flash('flash_notification.message',$message);
43
        $this->session->flash('flash_notification.type',$type);
0 ignored issues
show
Documentation introduced by
$type is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
44
        return $this;
45
    }
46
47
}