Completed
Push — master ( 1223fc...6af157 )
by Damien
05:06
created

ProviderRecord::getLoginPath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 13
cp 0
rs 9.8333
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: dsmrt
5
 * Date: 1/12/18
6
 * Time: 9:33 PM
7
 */
8
9
namespace flipbox\saml\sp\records;
10
11
use flipbox\ember\records\traits\StateAttribute;
12
use flipbox\saml\core\records\AbstractProvider;
13
use flipbox\saml\core\records\ProviderInterface;
14
use flipbox\saml\core\SamlPluginInterface;
15
use flipbox\saml\sp\Saml;
16
17
class ProviderRecord extends AbstractProvider implements ProviderInterface
18
{
19
20
    use StateAttribute;
21
22
    /**
23
     * The table alias
24
     */
25
    const TABLE_ALIAS = 'saml_sp_providers';
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function getLoginPath()
31
    {
32
        if ($this->type !== Saml::IDP) {
0 ignored issues
show
Documentation introduced by
The property type does not exist on object<flipbox\saml\sp\records\ProviderRecord>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
33
            return null;
34
        }
35
        return implode(
36
            DIRECTORY_SEPARATOR,
37
            [
38
                Saml::getInstance()->getSettings()->loginRequestEndpoint,
39
                $this->uid,
40
            ]
41
        );
42
    }
43
44
    /**
45
     * @inheritdoc
46
     */
47
    public function getLogoutPath()
48
    {
49
        if ($this->type !== Saml::IDP) {
0 ignored issues
show
Documentation introduced by
The property type does not exist on object<flipbox\saml\sp\records\ProviderRecord>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
50
            return null;
51
        }
52
        return implode(
53
            DIRECTORY_SEPARATOR,
54
            [
55
                Saml::getInstance()->getSettings()->logoutRequestEndpoint,
56
                $this->uid,
57
            ]
58
        );
59
    }
60
}
61