Completed
Push — master ( 0a7932...aee286 )
by Maksim
13s
created

CacheResolveEvent   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 95
wmc 7
c 1
b 0
f 0
lcom 0
cbo 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setPath() 0 4 1
A getPath() 0 4 1
A setFilter() 0 4 1
A getFilter() 0 4 1
A setUrl() 0 4 1
A getUrl() 0 4 1
A __construct() 0 6 1
1
<?php
2
3
namespace Liip\ImagineBundle\Events;
4
5
use Symfony\Component\EventDispatcher\Event;
6
7
class CacheResolveEvent extends Event
8
{
9
    /**
10
     * Resource path.
11
     *
12
     * @var string
13
     */
14
    protected $path;
15
16
    /**
17
     * Filter name.
18
     *
19
     * @var string
20
     */
21
    protected $filter;
22
23
    /**
24
     * Resource url.
25
     *
26
     * @var null
27
     */
28
    protected $url;
29
30
    /**
31
     * Init default event state.
32
     *
33
     * @param string      $path
34
     * @param string      $filter
35
     * @param null|string $url
36
     */
37
    public function __construct($path, $filter, $url = null)
38
    {
39
        $this->path = $path;
40
        $this->filter = $filter;
41
        $this->url = $url;
0 ignored issues
show
Documentation Bug introduced by
It seems like $url can also be of type string. However, the property $url is declared as type null. 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...
42
    }
43
44
    /**
45
     * Sets resource path.
46
     *
47
     * @param $path
48
     */
49
    public function setPath($path)
50
    {
51
        $this->path = $path;
52
    }
53
54
    /**
55
     * Returns resource path.
56
     *
57
     * @return string
58
     */
59
    public function getPath()
60
    {
61
        return $this->path;
62
    }
63
64
    /**
65
     * Sets filter name.
66
     *
67
     * @param $filter
68
     */
69
    public function setFilter($filter)
70
    {
71
        $this->filter = $filter;
72
    }
73
74
    /**
75
     * Returns filter name.
76
     *
77
     * @return string
78
     */
79
    public function getFilter()
80
    {
81
        return $this->filter;
82
    }
83
84
    /**
85
     * Sets resource url.
86
     *
87
     * @param $url
88
     */
89
    public function setUrl($url)
90
    {
91
        $this->url = $url;
92
    }
93
94
    /**
95
     * Returns resource url.
96
     */
97
    public function getUrl()
98
    {
99
        return $this->url;
100
    }
101
}
102