InvalidArgumentException::getExpectedType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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