Conditions | 5 |
Paths | 5 |
Total Lines | 38 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 0 |
1 | <?php |
||
18 | public static function collectionsPageHandler($segments) { |
||
19 | |||
20 | elgg_push_context('friends'); |
||
21 | |||
22 | $page = array_shift($segments); |
||
23 | |||
24 | switch ($page) { |
||
25 | case 'add': |
||
26 | $username = array_shift($segments); |
||
27 | echo elgg_view_resource('friends/collections/add', [ |
||
28 | 'username' => $username, |
||
29 | ]); |
||
30 | return true; |
||
31 | |||
32 | case 'edit': |
||
33 | $collection_id = array_shift($segments); |
||
34 | echo elgg_view_resource('friends/collections/edit', [ |
||
35 | 'collection_id' => $collection_id, |
||
36 | ]); |
||
37 | return true; |
||
38 | |||
39 | case 'view' : |
||
40 | $collection_id = array_shift($segments); |
||
41 | echo elgg_view_resource('friends/collections/view', [ |
||
42 | 'collection_id' => $collection_id, |
||
43 | ]); |
||
44 | return true; |
||
45 | |||
46 | case 'owner': |
||
47 | default : |
||
48 | $username = array_shift($segments); |
||
49 | echo elgg_view_resource('friends/collections/owner', [ |
||
50 | 'username' => $username, |
||
51 | ]); |
||
52 | return true; |
||
53 | } |
||
54 | |||
55 | return false; |
||
|
|||
56 | } |
||
58 |
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.