Passed
Pull Request — develop (#25)
by Barney
03:18
created

FormatterExceptionTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A msg() 0 7 1
A level() 0 7 1
1
<?php
2
/**
3
 * @codingStandardsIgnoreStart
4
 *
5
 * @author       Barney Hanlon <[email protected]>
6
 * @copyright    Barney Hanlon 2017
7
 * @license      https://opensource.org/licenses/MIT
8
 *
9
 * @codingStandardsIgnoreEnd
10
 */
11
12
namespace Shrikeh\GuzzleMiddleware\TimerLogger\Formatter\Traits;
13
14
use Exception;
15
16
/**
17
 * Trait FormatterStartExceptionTrait.
18
 */
19
trait FormatterExceptionTrait
20
{
21
    /**
22
     * @param \Exception|null $e An optional previous Exception
23
     *
24
     * @return static
25
     */
26
    public static function msg(
27
        Exception $e = null
28
    ) {
29
        return new static(
30
            static::MSG_MESSAGE,
0 ignored issues
show
Bug introduced by
The constant Shrikeh\GuzzleMiddleware...ptionTrait::MSG_MESSAGE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Unused Code introduced by
The call to Shrikeh\GuzzleMiddleware...ionTrait::__construct() has too many arguments starting with static::MSG_MESSAGE. ( Ignorable by Annotation )

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

30
        return /** @scrutinizer ignore-call */ new static(

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
31
            static::MSG_CODE,
0 ignored issues
show
Bug introduced by
The constant Shrikeh\GuzzleMiddleware...xceptionTrait::MSG_CODE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
32
            $e
33
        );
34
    }
35
36
    /**
37
     * @param \Exception|null $e An optional previous Exception
38
     *
39
     * @return static
40
     */
41
    public static function level(
42
        Exception $e = null
43
    ) {
44
        return new static(
45
            static::LEVEL_MESSAGE,
0 ignored issues
show
Bug introduced by
The constant Shrikeh\GuzzleMiddleware...ionTrait::LEVEL_MESSAGE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Unused Code introduced by
The call to Shrikeh\GuzzleMiddleware...ionTrait::__construct() has too many arguments starting with static::LEVEL_MESSAGE. ( Ignorable by Annotation )

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

45
        return /** @scrutinizer ignore-call */ new static(

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
46
            static::LEVEL_CODE,
0 ignored issues
show
Bug introduced by
The constant Shrikeh\GuzzleMiddleware...eptionTrait::LEVEL_CODE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
47
            $e
48
        );
49
    }
50
}
51