AbstractProfileContext::getProfileContext()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 12
rs 10
cc 4
nc 4
nop 0
1
<?php
2
3
/*
4
 * This file is part of the LightSAML-Core package.
5
 *
6
 * (c) Milos Tomic <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace LightSaml\Context\Profile;
13
14
use LightSaml\Context\AbstractContext;
15
use LightSaml\Error\LightSamlContextException;
16
17
abstract class AbstractProfileContext extends AbstractContext
18
{
19
    /**
20
     * @return ProfileContext
21
     */
22
    public function getProfileContext()
23
    {
24
        $result = $this;
25
        while ($result && false == $result instanceof ProfileContext) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
26
            $result = $result->getParent();
27
        }
28
29
        if ($result) {
0 ignored issues
show
introduced by
$result is of type null, thus it always evaluated to false.
Loading history...
30
            return $result;
31
        }
32
33
        throw new LightSamlContextException($this, 'Missing ProfileContext');
34
    }
35
}
36