Conditions | 6 |
Paths | 4 |
Total Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 6.972 |
Changes | 0 |
1 | <?php |
||
30 | 5 | public function onAfterInit() |
|
31 | { |
||
32 | 5 | $request = $this->owner->getRequest(); |
|
|
|||
33 | 5 | if ($request instanceof NullHTTPRequest) { |
|
34 | 2 | return; |
|
35 | } |
||
36 | |||
37 | 5 | $url = $this->owner->getRequest()->getURL(); |
|
38 | // This should never run on the 'partial' or 'ping' URL |
||
39 | 5 | if (strpos($url, 'partial') === false && strpos($url, 'ping') === false) { |
|
40 | // Clear session on start |
||
41 | $session = $this->owner->getRequest()->getSession(); |
||
42 | if ($session && $session->get(PartialSubmissionController::SESSION_KEY)) { |
||
43 | $session->clear(PartialSubmissionController::SESSION_KEY); |
||
44 | } |
||
45 | } |
||
46 | 5 | } |
|
47 | } |
||
48 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: