Failed Conditions
Push — preview-1.19.0 ( 7438ce...cca8d0 )
by Guilherme
12:04
created

EvaluateBadgesEvent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A registerBadges() 0 7 2
A getPerson() 0 3 1
A registerBadge() 0 3 1
1
<?php
2
3
namespace LoginCidadao\BadgesControlBundle\Event;
4
5
use Symfony\Component\EventDispatcher\Event;
6
use LoginCidadao\CoreBundle\Model\PersonInterface;
7
use LoginCidadao\BadgesControlBundle\Model\BadgeInterface;
8
9
class EvaluateBadgesEvent extends Event
10
{
11
12
    protected $person;
13
14 1
    public function __construct(PersonInterface $person)
15
    {
16 1
        $this->person = $person;
17 1
    }
18
19
    /**
20
     *
21
     * @return PersonInterface
22
     */
23 1
    public function getPerson()
24
    {
25 1
        return $this->person;
26
    }
27
28 1
    public function registerBadges(array $badges)
29
    {
30 1
        foreach ($badges as $badge) {
31 1
            $this->registerBadge($badge);
32
        }
33
34 1
        return $this;
35
    }
36
37 1
    public function registerBadge(BadgeInterface $badge)
38
    {
39 1
        $this->getPerson()->mergeBadges([$badge]);
40 1
    }
41
42
}
43