Completed
Push — master ( 14b48b...4568b1 )
by Anton
13s
created

ValidatorFormException::hasErrors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Bluz Framework Component
4
 *
5
 * @copyright Bluz PHP Team
6
 * @link      https://github.com/bluzphp/framework
7
 */
8
9
declare(strict_types=1);
10
11
namespace Bluz\Validator\Exception;
12
13
/**
14
 * Validator Exception
15
 *
16
 * @package  Bluz\Validator\Exception
17
 * @author   Anton Shevchuk
18
 */
19
class ValidatorFormException extends ValidatorException
20
{
21
    /**
22
     * @var array of error's messages
23
     */
24
    protected $errors;
25
26
    /**
27
     * @return array
28
     */
29 2
    public function getErrors(): array
30
    {
31 2
        return $this->errors;
32
    }
33
34
    /**
35
     * @param array $errors
36
     */
37
    public function setErrors(array $errors)
38
    {
39
        $this->errors = $errors;
40
    }
41
42
    /**
43
     * Add Error by field name
44
     *
45
     * @param  string $name
46
     * @param  string $message
47
     *
48
     * @return void
49
     */
50 3
    public function setError($name, $message)
51
    {
52 3
        $this->errors[$name] = $message;
53 3
    }
54
55
    /**
56
     * Has errors?
57
     *
58
     * @return bool
59
     */
60 5
    public function hasErrors() : bool
61
    {
62 5
        return (bool)count($this->errors);
63
    }
64
}
65