Completed
Push — master ( cb3eb0...9da439 )
by ARCANEDEV
04:01
created

SaveSettings   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 28
ccs 0
cts 8
cp 0
rs 10
wmc 2
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 4 1
A terminate() 0 4 1
1
<?php namespace Arcanesoft\Core\Http\Middleware;
2
3
use Arcanedev\Support\Http\Middleware;
4
use Closure;
5
6
/**
7
 * Class     SaveSettings
8
 *
9
 * @package  Arcanesoft\Core\Http\Middleware
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class SaveSettings extends Middleware
13
{
14
    /* -----------------------------------------------------------------
15
     |  Main Methods
16
     | -----------------------------------------------------------------
17
     */
18
19
    /**
20
     * Handle the request.
21
     *
22
     * @param  \Illuminate\Http\Request  $request
23
     * @param  \Closure                  $next
24
     *
25
     * @return mixed
26
     */
27
    public function handle($request, Closure $next)
28
    {
29
        return $next($request);
30
    }
31
32
    /**
33
     * Terminate the request.
34
     */
35
    public function terminate()
36
    {
37
        settings()->save();
0 ignored issues
show
Bug introduced by
The method save does only exist in Arcanedev\LaravelSettings\Contracts\Store, but not in Arcanedev\LaravelSettings\Contracts\Manager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
38
    }
39
}
40