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

Errorable   A

Complexity

Total Complexity 32

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 63.64%

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 32
c 3
b 1
f 1
lcom 1
cbo 0
dl 0
loc 62
ccs 14
cts 22
cp 0.6364
rs 9.6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getArrErrors() 0 7 2
A addError() 0 7 2
A addArrErrors() 0 9 3
A resetErrors() 0 4 1
A hasErrors() 0 8 2
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