Test Failed
Pull Request — master (#18)
by
unknown
02:56
created

InvalidSelectionException::getValidOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace GloBee\PaymentApi\Exceptions\Validation;
4
5
class InvalidSelectionException extends ValidationException
6
{
7
    /**
8
     * @var array
9
     */
10
    private $options;
11
12
    /**
13
     * InvalidSelectionException constructor.
14
     *
15
     * @param string $field
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
16
     * @param mixed  $value
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
17
     * @param array $options
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
18
     */
19
    public function __construct($field, $value, array $options)
0 ignored issues
show
Coding Style introduced by
Type hint "string" missing for $field
Loading history...
20
    {
21
        $this->options = $options;
22
        $message = sprintf('The selected %s is invalid.', $field);
23
        $error = [
24
            'type' => 'invalid_selection',
25
            'extra' => $options,
26
            'field' => $field,
27
            'message' => $message,
28
        ];
29
        parent::__construct([$error], $message);
30
    }
31
32
    /**
33
     * @return array
34
     */
35
    public function getValidOptions()
36
    {
37
        return $this->options;
38
    }
39
}
40