Passed
Push — develop ( 544241...772ac1 )
by Daniel
03:40
created

action_handler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 12 2
A __construct() 0 3 1
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\content\services\actions;
11
12
use Symfony\Component\DependencyInjection\Container;
13
14
class action_handler
15
{
16
	/** @var Container */
17
	protected $phpbb_container;
18
19
	/**
20
	 * Constructor
21
	 *
22
	 * @param Container		$phpbb_container		Service container
23
	 */
24
	public function __construct(Container $phpbb_container)
25
	{
26
		$this->phpbb_container = $phpbb_container;
27
	}
28
29
	/**
30
	 * @param string $mode topic|type
31
	 * @param string $action
32
	 * @return \blitze\content\services\actions\action_interface
33
	 * @throws \blitze\sitemaker\exception\out_of_bounds
34
	 */
35
	public function create($mode, $action)
36
	{
37
		$service_name = 'blitze.content.actions.' . $mode . '.' . $action;
38
		if (!$this->phpbb_container->has($service_name))
39
		{
40
			throw new \blitze\sitemaker\exception\out_of_bounds(array($action, 'INVALID_REQUEST'));
41
		}
42
43
		$service = $this->phpbb_container->get($service_name);
44
45
		/** @var \blitze\content\services\actions\action_interface $service */
46
		return $service;
47
	}
48
}
49