RequestValidateException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 9.9
cc 1
nc 1
nop 5
crap 1
1
<?php
2
3
namespace indigerd\scenarios\exception;
4
5
use Throwable;
6
use yii\web\Request;
7
8
class RequestValidateException extends \Exception
9
{
10
    protected $request;
11
12
    protected $errorCollection = [];
13
14 1
    public function __construct(
15
        Request $request,
16
        array $errorCollection = [],
17
        string $message = "",
18
        int $code = 0,
19
        Throwable $previous = null
20
    ) {
21 1
        $this->request = $request;
22 1
        $this->errorCollection = $errorCollection;
23 1
        parent::__construct($message, $code, $previous);
24 1
    }
25
26
    public function getRequest() : Request
27
    {
28
        return $this->request;
29
    }
30
31
    public function getErrorCollection() : array
32
    {
33
        return $this->errorCollection;
34
    }
35
36
    public function getFirstError(): string
37
    {
38
        return current($this->errorCollection)[0];
39
    }
40
}
41