SubjectNameIdAction   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 32
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A doExecute() 0 10 3
1
<?php
2
3
/*
4
 * This file is part of the LightSAML-IDP package.
5
 *
6
 * (c) Milos Tomic <[email protected]>
7
 *
8
 * This source file is subject to the GPL-3 license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace LightSaml\Idp\Action\Assertion\Outbound;
13
14
use LightSaml\Action\Assertion\AbstractAssertionAction;
15
use LightSaml\Context\Profile\AssertionContext;
16
use LightSaml\Model\Assertion\Subject;
17
use LightSaml\Provider\NameID\NameIdProviderInterface;
18
use Psr\Log\LoggerInterface;
19
20
/**
21
 * Creates Subject if not already created, and sets NameID to it with the value provided by name id provider.
22
 */
23
class SubjectNameIdAction extends AbstractAssertionAction
24
{
25
    /** @var NameIDProviderInterface */
26
    protected $nameIdProvider;
27
28
    /**
29
     * @param LoggerInterface         $logger
30
     * @param NameIDProviderInterface $nameIdProvider
31
     */
32
    public function __construct(LoggerInterface $logger, NameIdProviderInterface $nameIdProvider)
33
    {
34
        parent::__construct($logger);
35
36
        $this->nameIdProvider = $nameIdProvider;
0 ignored issues
show
Documentation Bug introduced by
It seems like $nameIdProvider of type object<LightSaml\Provide...ameIdProviderInterface> is incompatible with the declared type object<LightSaml\Idp\Act...ameIDProviderInterface> of property $nameIdProvider.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
37
    }
38
39
    /**
40
     * @param AssertionContext $context
41
     *
42
     * @return void
43
     */
44
    protected function doExecute(AssertionContext $context)
45
    {
46
        $nameId = $this->nameIdProvider->getNameID($context);
47
        if ($nameId) {
48
            if (null == $context->getAssertion()->getSubject()) {
49
                $context->getAssertion()->setSubject(new Subject());
50
            }
51
            $context->getAssertion()->getSubject()->setNameID($nameId);
52
        }
53
    }
54
}
55