Passed
Pull Request — master (#25)
by Brian
07:28
created

flash()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 2
b 0
f 0
nc 2
nop 2
dl 0
loc 14
rs 10
1
<?php
2
3
use Spatie\Flash\Flash;
4
use Spatie\Flash\Message;
5
6
/**
7
 * @param string $text
8
 * @param string|array $class
9
 */
10
function flash(string $text = null, $class = null): Flash
11
{
12
    /** @var \Spatie\Flash\Flash $flash */
13
    $flash = app(Flash::class);
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

13
    $flash = /** @scrutinizer ignore-call */ app(Flash::class);
Loading history...
14
15
    if (is_null($text)) {
16
        return $flash;
17
    }
18
19
    $message = new Message($text, $class);
20
21
    $flash->flash($message);
22
23
    return $flash;
24
}
25