Completed
Pull Request — master (#840)
by Guilherme
04:45
created

SupportHandlerDecorator::getPhoneMetadata()   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
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace PROCERGS\LoginCidadao\CoreBundle\Service;
12
13
use LoginCidadao\CoreBundle\Entity\PersonRepository;
14
use LoginCidadao\CoreBundle\Entity\SentEmail;
15
use LoginCidadao\CoreBundle\Model\IdentifiablePersonInterface;
16
use LoginCidadao\CoreBundle\Model\PersonInterface;
17
use LoginCidadao\SupportBundle\Model\SupportPerson;
18
use LoginCidadao\SupportBundle\Service\SupportHandlerInterface;
19
use PROCERGS\LoginCidadao\CoreBundle\Helper\MeuRSHelper;
20
21
class SupportHandlerDecorator implements SupportHandlerInterface
22
{
23
    /** @var SupportHandlerInterface */
24
    private $parent;
25
26
    /** @var MeuRSHelper */
27
    private $rsHelper;
28
29
    /** @var PersonRepository */
30
    private $personRepo;
31
32
    /**
33
     * SupportHandlerDecorator constructor.
34
     * @param SupportHandlerInterface $parent
35
     * @param MeuRSHelper $rsHelper
36
     * @param PersonRepository $personRepo
37
     */
38 2
    public function __construct(SupportHandlerInterface $parent, MeuRSHelper $rsHelper, PersonRepository $personRepo)
39
    {
40 2
        $this->parent = $parent;
41 2
        $this->rsHelper = $rsHelper;
42 2
        $this->personRepo = $personRepo;
43 2
    }
44
45 1
    public function getThirdPartyConnections(IdentifiablePersonInterface $person): array
46
    {
47 1
        if (!$person instanceof PersonInterface) {
48 1
            $person = $this->personRepo->find($person->getId());
49
        }
50
51 1
        $connections = $this->parent->getThirdPartyConnections($person);
0 ignored issues
show
Bug introduced by
It seems like $person can also be of type null; however, parameter $person of LoginCidadao\SupportBund...ThirdPartyConnections() does only seem to accept LoginCidadao\CoreBundle\...tifiablePersonInterface, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

51
        $connections = $this->parent->getThirdPartyConnections(/** @scrutinizer ignore-type */ $person);
Loading history...
52
53 1
        if ($person instanceof PersonInterface) {
54 1
            $personRS = $this->rsHelper->getPersonMeuRS($person, true);
55
56 1
            $connections['nfg'] = $personRS->getNfgAccessToken() !== null;
57
        }
58
59 1
        return $connections;
60
    }
61
62 1
    public function getSupportPerson($id): SupportPerson
63
    {
64 1
        return $this->parent->getSupportPerson($id);
65
    }
66
67 1
    public function getPhoneMetadata(IdentifiablePersonInterface $person): array
68
    {
69 1
        return $this->parent->getPhoneMetadata($person);
70
    }
71
72 1
    public function getInitialMessage($ticket): ?SentEmail
73
    {
74 1
        return $this->parent->getInitialMessage($ticket);
75
    }
76
77 1
    public function getValidationMap(SupportPerson $person): array
78
    {
79 1
        return $this->parent->getValidationMap($person);
80
    }
81
}
82