Completed
Push — develop ( de7659...415144 )
by Daniel
09:44
created

add_item   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 91.67%

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 2
c 5
b 0
f 1
lcom 1
cbo 5
dl 0
loc 27
ccs 11
cts 12
cp 0.9167
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 20 2
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2013 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\sitemaker\services\menus\action;
11
12
class add_item extends base_action
13
{
14
	/**
15
	 * {@inheritdoc}
16
	 * @throws \blitze\sitemaker\exception\out_of_bounds
17
	 */
18 1
	public function execute()
19
	{
20 1
		$menu_id = $this->request->variable('menu_id', 0);
21
22 1
		$menu_mapper = $this->mapper_factory->create('menus', 'menus');
23 1
		$items_mapper = $this->mapper_factory->create('menus', 'items');
24
25 1
		if ($menu_mapper->load(array('menu_id', '=', $menu_id)) === null)
26 1
		{
27
			throw new \blitze\sitemaker\exception\out_of_bounds('MENU_NOT_FOUND');
28
		}
29
30 1
		$entity = $items_mapper->create_entity(array(
31 1
			'menu_id'	=> $menu_id,
32 1
		));
33
34 1
		$entity = $items_mapper->save($entity);
35
36 1
		return $entity->to_array();
37
	}
38
}
39