InteractsWithFlashData::flashExcept()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 0
cp 0
crap 6
rs 10
1
<?php
2
3
/**
4
 * This file is part of Blitz PHP framework.
5
 *
6
 * (c) 2022 Dimitri Sitchet Tomkeu <[email protected]>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace BlitzPHP\Http\Concerns;
13
14
use BlitzPHP\Wolke\Model;
0 ignored issues
show
Bug introduced by
The type BlitzPHP\Wolke\Model was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
16
/**
17
 * @credit <a href="http://laravel.com/">Laravel - Illuminate\Http\Concerns\InteractsWithFlashData</a>
18
 */
19
trait InteractsWithFlashData
20
{
21
    /**
22
     * Récupérer un ancien élément d'entrée.
23
     *
24
     * @param array|Model|string|null $default
25
     *
26
     * @return array|string|null
27
     */
28
    public function old(?string $key = null, $default = null)
29
    {
30
        if (class_exists(Model::class) && $default instanceof Model) {
31
            $default = $default->getAttribute($key);
32
        }
33
34
        if (null !== $value = $this->getOldInput($key)) {
0 ignored issues
show
Bug introduced by
It seems like getOldInput() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

34
        if (null !== $value = $this->/** @scrutinizer ignore-call */ getOldInput($key)) {
Loading history...
35
            return $value;
36
        }
37
38
        return $default;
39
    }
40
41
    /**
42
     * Flashez l'entrée de la demande actuelle à la session.
43
     */
44
    public function flash(): void
45
    {
46
        $this->session()->flashInput($this->input());
0 ignored issues
show
Bug introduced by
It seems like session() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

46
        $this->/** @scrutinizer ignore-call */ 
47
               session()->flashInput($this->input());
Loading history...
Bug introduced by
It seems like input() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

46
        $this->session()->flashInput($this->/** @scrutinizer ignore-call */ input());
Loading history...
47
    }
48
49
    /**
50
     * Ne flashez qu'une partie des entrées de la session.
51
     *
52
     * @param array|mixed $keys
53
     */
54
    public function flashOnly($keys): void
55
    {
56
        $this->session()->flashInput(
57
            $this->only(is_array($keys) ? $keys : func_get_args())
0 ignored issues
show
Bug introduced by
It seems like only() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

57
            $this->/** @scrutinizer ignore-call */ 
58
                   only(is_array($keys) ? $keys : func_get_args())
Loading history...
58
        );
59
    }
60
61
    /**
62
     * Ne flashez qu'une partie des entrées de la session.
63
     *
64
     * @param array|mixed $keys
65
     */
66
    public function flashExcept($keys): void
67
    {
68
        $this->session()->flashInput(
69
            $this->except(is_array($keys) ? $keys : func_get_args())
0 ignored issues
show
Bug introduced by
It seems like except() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

69
            $this->/** @scrutinizer ignore-call */ 
70
                   except(is_array($keys) ? $keys : func_get_args())
Loading history...
70
        );
71
    }
72
73
    /**
74
     * Videz toutes les anciennes entrées de la session.
75
     */
76
    public function flush()
77
    {
78
        $this->session()->flashInput([]);
79
    }
80
}
81