save_item   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 25
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 19 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 save_item extends base_action
13
{
14
	/**
15
	 * {@inheritdoc}
16
	 * @throws \blitze\sitemaker\exception\out_of_bounds
17
	 */
18 2
	public function execute()
19
	{
20 2
		$item_id = $this->request->variable('item_id', 0);
21
22 2
		$item_mapper = $this->mapper_factory->create('items');
23
24
		/** @type \blitze\sitemaker\model\entity\item $entity */
25 2
		if (($entity = $item_mapper->load(array('item_id', '=', $item_id))) === null)
26 2
		{
27 1
			throw new \blitze\sitemaker\exception\out_of_bounds('item_id');
28
		}
29
30 1
		$entity->set_item_title($this->request->variable('item_title', '', true))
31 1
			->set_item_url($this->request->variable('item_url', ''))
32 1
			->set_item_target($this->request->variable('item_target', 0));
33
34 1
		$entity = $item_mapper->save($entity);
35
36 1
		return $entity->to_array();
37
	}
38
}
39