Test Setup Failed
Push — master ( 5f1ff1...213bb6 )
by Php Easy Api
03:56
created

ExceptionExtender   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 54
rs 10
c 0
b 0
f 0
wmc 8

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 3
A request() 0 7 4
A getResult() 0 3 1
1
<?php
2
3
namespace Resta\Exception;
4
5
use Resta\Contracts\ApplicationContracts;
6
use Resta\Foundation\ApplicationProvider;
7
8
class ExceptionExtender extends ApplicationProvider
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $result;
14
15
    /**
16
     * @var array
17
     */
18
    protected $extender = ['request'];
19
20
    /**
21
     * ExceptionExtender constructor.
22
     * @param ApplicationContracts $app
23
     * @param array $result
24
     */
25
    public function __construct(ApplicationContracts $app,$result=array())
26
    {
27
        parent::__construct($app);
28
29
        $this->result = $result;
30
31
        foreach($this->extender as $item){
32
            if(method_exists($this,$item)){
33
                $this->{$item}();
34
            }
35
        }
36
    }
37
38
    /**
39
     * get request expected items
40
     *
41
     * @return void
42
     */
43
    public function request()
44
    {
45
        // we will look at the requestExpected container value to show
46
        // the expected values ​​for the request object in the exception output.
47
        if(app()->has('requestExpected') && config('app.requestWithError')===true){
0 ignored issues
show
Bug introduced by
The method has() does not exist on Resta\Contracts\ApplicationHelpersContracts. ( Ignorable by Annotation )

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

47
        if(app()->/** @scrutinizer ignore-call */ has('requestExpected') && config('app.requestWithError')===true){

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
            if($requestExpected = app()->get('requestExpected')){
0 ignored issues
show
Bug introduced by
The method get() does not exist on Resta\Contracts\ApplicationHelpersContracts. ( Ignorable by Annotation )

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

48
            if($requestExpected = app()->/** @scrutinizer ignore-call */ get('requestExpected')){

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
                $this->result['request']['expected'] = $requestExpected;
50
            }
51
        }
52
    }
53
54
    /**
55
     * get result for exception
56
     *
57
     * @return array
58
     */
59
    public function getResult()
60
    {
61
        return $this->result;
62
    }
63
}