Completed
Push — master ( 9e4d7b...c3f58e )
by Gabriel
03:57 queued 11s
created

HasErrorsTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 28.57%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
dl 0
loc 29
ccs 2
cts 7
cp 0.2857
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addError() 0 5 1
A isError() 0 3 1
A getErrors() 0 3 1
1
<?php
2
3
namespace Nip\Form\Elements\Traits;
4
5
use Nip\Form\Elements\AbstractElement;
6
7
/**
8
 * Trait HasErrorsTrait
9
 * @package Nip\Form\Elements\Traits
10
 */
11
trait HasErrorsTrait
12
{
13
    protected $_errors = [];
14
15
    /**
16
     * @param $message
17
     * @return $this
18
     */
19
    public function addError($message)
20
    {
21
        $this->_errors[] = $message;
22
23
        return $this;
24
    }
25
26
    /**
27
     * @return array
28
     */
29
    public function getErrors()
30
    {
31
        return $this->_errors;
32
    }
33
34
    /**
35
     * @return bool
36
     */
37 8
    public function isError()
38
    {
39 8
        return count($this->_errors) > 0;
40
    }
41
}
42