Completed
Push — master ( 78d2a6...d225ab )
by Lorenzo
02:05
created

Errorable::resetErrors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Padosoft\TesseraSanitaria\traits;
4
5
/**
6
 * Class Errorable
7
 * @package Padosoft\TesseraSanitaria\traits
8
 */
9
trait Errorable
10
{
11
	/**
12
	 * @var array
13
	 */
14
	protected $arrErrors = array();
15
16
	/**
17
	 * @return array
18
	 */
19 3
	public function getArrErrors()
20
	{
21 3
		if(!is_array($this->arrErrors)){
22
			$this->arrErrors = array();
23
		}
24 3
		return $this->arrErrors;
25
	}
26
27
	/**
28
	 * @param $str
29
	 */
30 3
	public function addError($str)
31
	{
32 3
		if($str == ""){
33
			return;
34
		}
35 3
		$this->arrErrors[] = $str;
36 3
	}
37
38
	/**
39
	 * @param $add
40
	 */
41
	public function addArrErrors($add)
42
	{
43
		if(!is_array($add) || count($add)<1){
44
			return;
45
		}
46
47
		$this->arrErrors = array_merge($this->arrErrors, $add);
48
49
	}
50
51
	/**
52
	 *
53
	 */
54 3
	public function resetErrors()
55
	{
56 3
		$this->arrErrors = array();
57 3
	}
58
59
    /**
60
     * @return bool
61
     */
62 3
    public function hasErrors()
63
    {
64 3
        if(count($this->getArrErrors())>0){
65 3
            return true;
66
        }else{
67 3
            return false;
68
        }
69
    }
70
}
71