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

EvaluateBadgesEvent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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