InvalidArgumentException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 14
c 1
b 0
f 0
dl 0
loc 47
ccs 14
cts 14
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getActualType() 0 3 1
A getExpectedType() 0 3 1
A __construct() 0 12 1
1
<?php
2
3
namespace GloBee\PaymentApi\Exceptions\Validation;
4
5
class InvalidArgumentException extends ValidationException
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $expectedType;
11
12
    /**
13
     * @var string
14
     */
15
    protected $actualType;
16
17
    /**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$field" missing
Loading history...
18
     * InvalidArgumentException constructor.
19
     *
20
     * @param        $field
0 ignored issues
show
Coding Style introduced by
Missing parameter name
Loading history...
21
     * @param string $expectedType
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
22
     * @param mixed  $actual
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
23
     */
24 9
    public function __construct($field, $expectedType, $actual)
0 ignored issues
show
Coding Style introduced by
Type hint "field" missing for
Loading history...
Coding Style introduced by
Type hint "string" missing for $expectedType
Loading history...
25
    {
26 9
        $this->expectedType = $expectedType;
27 9
        $this->actualType = gettype($actual);
28 9
        $message = sprintf('Expected %s but found %s.', $this->expectedType, $this->actualType);
29
        $error = [
30 9
            'type' => 'invalid_argument',
31 9
            'extra' => [$this->expectedType, $this->actualType],
32 9
            'field' => $field,
33 9
            'message' => $message,
34
        ];
35 9
        parent::__construct([$error], $message);
36 9
    }
37
38
    /**
39
     * @return string
40
     */
41 1
    public function getExpectedType()
42
    {
43 1
        return $this->expectedType;
44
    }
45
46
    /**
47
     * @return string
48
     */
49 1
    public function getActualType()
50
    {
51 1
        return $this->actualType;
52
    }
53
}
54