Passed
Pull Request — master (#347)
by Mirko
09:07
created

ErrorTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 3
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addError() 0 4 1
A hasErrors() 0 4 1
A getErrors() 0 4 1
1
<?php
2
3
namespace AppBundle\Service\Traits;
4
5
trait ErrorTrait
6
{
7
    /**
8
     * @var array
9
     */
10
    protected $errors = [];
11
12
    /**
13
     * @param string $text
14
     *
15
     * @return void
16
     */
17
    protected function addError($text)
18
    {
19
        $this->errors[] = $text;
20
    }
21
22
    /**
23
     * @return bool
24
     */
25
    public function hasErrors()
26
    {
27
        return count($this->errors) > 0;
28
    }
29
30
    /**
31
     * @return array
32
     */
33
    public function getErrors()
34
    {
35
        return $this->errors;
36
    }
37
}
38