Passed
Push — master ( 5f9e30...9e7e6b )
by Dedipyaman
02:07
created

Result::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: dedipyaman
5
 * Date: 1/23/19
6
 * Time: 2:07 AM
7
 */
8
9
namespace Phypes;
10
11
use Phypes\Error\Error;
12
13
class Result
14
{
15
    private $valid;
16
    private $errors = [];
17
18
    public function __construct(bool $valid, Error... $errors)
19
    {
20
        $this->valid = $valid;
21
        $this->errors = $errors;
22
    }
23
24
    public function isValid() : bool
25
    {
26
        return $this->valid;
27
    }
28
29
    /**
30
     * @return array
31
     */
32
    public function getErrors(): array
33
    {
34
35
        return $this->errors;
36
    }
37
38
    public function getFirstError() : ?Error
39
    {
40
        if (!$this->valid) {
41
            return $this->errors[0];
42
        }
43
        return null;
44
    }
45
}