Completed
Push — master ( 3afa9c...88f100 )
by Tim
02:23
created

ModuleInfo::getParams()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * AppserverIo\Psr\Security\Auth\Login\LoginException
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2015 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io-psr/security
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\Psr\Security\Auth\Login;
22
23
use AppserverIo\Lang\String;
24
use AppserverIo\Collections\HashMap;
25
26
/**
27
 * Contain's information about a login module's configuration.
28
 *
29
 * @author    Tim Wagner <[email protected]>
30
 * @copyright 2015 TechDivision GmbH <[email protected]>
31
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
32
 * @link      https://github.com/appserver-io-psr/security
33
 * @link      http://www.appserver.io
34
 */
35
class ModuleInfo
36
{
37
38
    /**
39
     * The login module's class name.
40
     *
41
     * @var \AppserverIo\Lang\String
42
     */
43
    protected $type;
44
45
    /**
46
     * The login module's initialization parameters.
47
     *
48
     * @var \AppserverIo\Collections\HashMap
49
     */
50
    protected $params;
51
52
    /**
53
     * Initializes the instance with the login module name and initialization params.
54
     *
55
     * @param \AppserverIo\Lang\String         $type   The login module class name
56
     * @param \AppserverIo\Collections\HashMap $params The parameters for the initialize() method
57
     */
58
    public function __construct(String $type, HashMap $params)
59
    {
60
        $this->type = $type;
0 ignored issues
show
Documentation Bug introduced by
It seems like $type can also be of type string. However, the property $type is declared as type object<AppserverIo\Lang\String>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
61
        $this->params = $params;
62
    }
63
64
    /**
65
     * Return's the login modules class name.
66
     *
67
     * @return \AppserverIo\Lang\String The class name
68
     */
69
    public function getType()
70
    {
71
        return $this->type;
72
    }
73
74
    /**
75
     * Return's the login modules initialization parameters.
76
     *
77
     * @return \AppserverIo\Collections\HashMap The parameters
78
     */
79
    public function getParams()
80
    {
81
        return $this->params;
82
    }
83
}
84