Passed
Push — master ( c0a3a7...3b84a4 )
by Jeroen
58:51
created

Router::collectionsPageHandler()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 38
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
cc 5
eloc 25
nc 5
nop 1
dl 0
loc 38
ccs 0
cts 24
cp 0
crap 30
rs 8.439
c 0
b 0
f 0
1
<?php
2
3
namespace Elgg\Friends\Collections;
4
5
/**
6
 * Page handler for friends collections
7
 */
8
class Router {
9
10
	/**
11
	 * Page handler for friends collections
12
	 *
13
	 * @param array $segments URL segments
14
	 *
15
	 * @return bool
16
	 * @access private
17
	 */
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;
0 ignored issues
show
Unused Code introduced by
return false is not reachable.

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 or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

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.

Loading history...
56
	}
57
}
58