Completed
Push — master ( 825b72...88de5a )
by Nazar
05:05
created

Controller   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A admin_categories_get() 0 12 3
1
<?php
2
/**
3
 * @package   Static Pages
4
 * @category  modules
5
 * @author    Nazar Mokrynskyi <[email protected]>
6
 * @copyright Copyright (c) 2016, Nazar Mokrynskyi
7
 * @license   MIT License, see license.txt
8
 */
9
namespace cs\modules\Static_pages\api;
10
use
11
	cs\ExitException,
12
	cs\modules\Static_pages\Categories;
13
14
class Controller {
15
	/**
16
	 * @param \cs\Request $Request
17
	 *
18
	 * @return array
19
	 *
20
	 * @throws ExitException
21
	 */
22
	public static function admin_categories_get ($Request) {
23
		$id         = $Request->route_ids(0);
24
		$Categories = Categories::instance();
25
		if ($id) {
26
			$data = $Categories->get($id);
27
			if (!$data) {
28
				throw new ExitException(404);
29
			}
30
			return $data;
31
		}
32
		return $Categories->get_all();
33
	}
34
}
35