RequestValidateException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 45.45%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 33
c 0
b 0
f 0
ccs 5
cts 11
cp 0.4545
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getRequest() 0 4 1
A getErrorCollection() 0 4 1
A getFirstError() 0 4 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