Errorable   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 3 Features 1
Metric Value
wmc 10
c 5
b 3
f 1
lcom 1
cbo 0
dl 0
loc 59
ccs 19
cts 19
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getArrErrors() 0 4 2
A resetErrors() 0 4 1
A addError() 0 7 2
A addArrErrors() 0 9 3
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 48
    public function getArrErrors()
20
    {
21 48
        return (is_array($this->arrErrors) ? $this->arrErrors : array());
22
    }
23
24
    /**
25
     * @param $str
26
     */
27 45
    public function addError($str)
28
    {
29 45
        if ($str == "") {
30 3
            return;
31
        }
32 45
        $this->arrErrors[] = $str;
33 45
    }
34
35
    /**
36
     * @param $add
37
     */
38 3
    public function addArrErrors($add)
39
    {
40 3
        if (!is_array($add) || count($add) < 1) {
41 3
            return;
42
        }
43
44 3
        $this->arrErrors = array_merge($this->arrErrors, $add);
45
46 3
    }
47
48
    /**
49
     *
50
     */
51 48
    public function resetErrors()
52
    {
53 48
        $this->arrErrors = array();
54 48
    }
55
56
    /**
57
     * @return bool
58
     */
59 48
    public function hasErrors()
60
    {
61 48
        if (count($this->getArrErrors()) > 0) {
62 48
            return true;
63
        } else {
64 48
            return false;
65
        }
66
    }
67
}
68