Completed
Push — cache ( ce1318 )
by Akihito
11s
created

StorageExpiryModule   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 39
ccs 0
cts 9
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A configure() 0 4 1
1
<?php
2
/**
3
 * This file is part of the BEAR.QueryRepository package.
4
 *
5
 * @license http://opensource.org/licenses/MIT MIT
6
 */
7
namespace BEAR\QueryRepository;
8
9
use BEAR\RepositoryModule\Annotation\ExpiryConfig;
10
use Ray\Di\AbstractModule;
11
12
class StorageExpiryModule extends AbstractModule
13
{
14
    /**
15
     * @var int
16
     */
17
    private $short;
18
19
    /**
20
     * @var int
21
     */
22
    private $medium;
23
24
    /**
25
     * @var int
26
     */
27
    private $long;
28
29
    /**
30
     * @param int            $short
31
     * @param int            $medium
32
     * @param int            $long
33
     * @param AbstractModule $module
34
     */
35
    public function __construct($short, $medium, $long, AbstractModule $module = null)
0 ignored issues
show
Unused Code introduced by
The parameter $medium is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The method parameter $medium is never used
Loading history...
36
    {
37
        $this->short = $short;
38
        $this->medium = $module;
0 ignored issues
show
Documentation Bug introduced by
It seems like $module can also be of type object<Ray\Di\AbstractModule>. However, the property $medium is declared as type integer. 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...
39
        $this->long = $long;
40
        parent::__construct($module);
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    protected function configure()
47
    {
48
        $this->bind()->annotatedWith(ExpiryConfig::class)->toInstance(new Expiry($this->short, $this->medium, $this->long));
49
    }
50
}
51