save_item::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 0
dl 0
loc 19
ccs 11
cts 11
cp 1
crap 2
rs 9.9666
c 0
b 0
f 0
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