1 | <?php |
||
12 | class PluginClientBuilder implements PluginClientBuilderInterface |
||
13 | { |
||
14 | /** |
||
15 | * @var Plugin[] |
||
16 | */ |
||
17 | protected $plugins = []; |
||
18 | |||
19 | /** |
||
20 | * @var bool |
||
21 | */ |
||
22 | protected $rebuildClient = true; |
||
23 | |||
24 | /** |
||
25 | * The last created client with the plugins |
||
26 | * |
||
27 | * @var PluginClient |
||
28 | */ |
||
29 | private $pluginClient; |
||
30 | |||
31 | /** |
||
32 | * The object that sends HTTP messages |
||
33 | * |
||
34 | * @var HttpClient |
||
35 | */ |
||
36 | private $httpClient; |
||
37 | |||
38 | /** |
||
39 | * |
||
40 | * @param HttpClient $httpClient |
||
41 | */ |
||
42 | public function __construct(HttpClient $httpClient = null) |
||
46 | |||
47 | /** |
||
48 | * Add a new plugin to the end of the plugin chain. |
||
49 | * |
||
50 | * @param Plugin $plugin |
||
51 | */ |
||
52 | public function addPlugin(Plugin $plugin) |
||
57 | |||
58 | /** |
||
59 | * Remove a plugin by its fully qualified class name (FQCN). |
||
60 | * |
||
61 | * @param string $fqcn |
||
62 | */ |
||
63 | public function removePlugin($fqcn) |
||
72 | |||
73 | /** |
||
74 | * Alias for removePlugin and addPlugin |
||
75 | * |
||
76 | * @param Plugin $plugin |
||
77 | */ |
||
78 | public function replacePlugin(Plugin $plugin) |
||
83 | |||
84 | /** |
||
85 | * Get all plugins |
||
86 | * |
||
87 | * @return Plugin[] |
||
88 | */ |
||
89 | public function getPlugins() |
||
93 | |||
94 | /** |
||
95 | * This will overwrite all existing plugins |
||
96 | * |
||
97 | * @param Plugin[] $plugins |
||
98 | * |
||
99 | * @return PluginClientBuilder |
||
100 | */ |
||
101 | public function setPlugins($plugins) |
||
106 | |||
107 | /** |
||
108 | * @return PluginClient |
||
109 | */ |
||
110 | public function buildClient() |
||
125 | |||
126 | /** |
||
127 | * @return boolean |
||
128 | */ |
||
129 | public function isModified() |
||
133 | |||
134 | /** |
||
135 | * @param HttpClient $httpClient |
||
136 | */ |
||
137 | public function setHttpClient(HttpClient $httpClient) |
||
142 | |||
143 | /** |
||
144 | * @return HttpClient |
||
145 | */ |
||
146 | public function getHttpClient() |
||
150 | |||
151 | /** |
||
152 | * Make sure to move the cache plugin to the end of the chain |
||
153 | */ |
||
154 | private function pushBackCachePlugin() |
||
168 | } |
||
169 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.