Errorable::resetErrors()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
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 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