InvalidSelectionException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 11
ccs 8
cts 8
cp 1
rs 10
cc 1
nc 1
nop 3
crap 1
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 1
    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 1
        $this->options = $options;
22 1
        $message = sprintf('The selected %s is invalid.', $field);
23
        $error = [
24 1
            'type' => 'invalid_selection',
25 1
            'extra' => $options,
26 1
            'field' => $field,
27 1
            'message' => $message,
28
        ];
29 1
        parent::__construct([$error], $message);
30 1
    }
31
32
    /**
33
     * @return array
34
     */
35 1
    public function getValidOptions()
36
    {
37 1
        return $this->options;
38
    }
39
}
40