add_bulk::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
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 18
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 add_bulk extends base_action
13
{
14
	/**
15
	 * {@inheritdoc}
16
	 * @throws \blitze\sitemaker\exception\out_of_bounds
17
	 */
18 6
	public function execute()
19
	{
20 6
		$menu_id = $this->request->variable('menu_id', 0);
21 6
		$parent_id = $this->request->variable('parent_id', 0);
22 6
		$bulk_list = $this->request->variable('add_list', '', true);
23
24 6
		$menu_mapper = $this->mapper_factory->create('menus');
25 6
		$items_mapper = $this->mapper_factory->create('items');
26
27 6
		if ($menu_mapper->load(array('menu_id', '=', $menu_id)) === null)
28 6
		{
29 1
			throw new \blitze\sitemaker\exception\out_of_bounds('menu_id');
30
		}
31
32
		/** @type \blitze\sitemaker\model\mapper\items $items_mapper */
33 5
		$collection = $items_mapper->add_items($menu_id, $parent_id, $bulk_list);
34
35 3
		return $this->get_items($collection);
36
	}
37
}
38