Completed
Push — 4.0 ( 19a36c...8b2e11 )
by Olivier
07:31
created

ClosureController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A action() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the ICanBoogie package.
5
 *
6
 * (c) Olivier Laviale <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ICanBoogie\Routing;
13
14
use ICanBoogie\HTTP\Request;
15
16
/**
17
 * Controller wrapper for closures.
18
 */
19
final class ClosureController extends Controller
20
{
21
	/**
22
	 * @var \Closure
23
	 */
24
	private $closure;
25
26
	/**
27
	 * @param \Closure $closure
28
	 */
29
	public function __construct(\Closure $closure)
30
	{
31
		$this->closure = \Closure::bind($closure, $this);
32
	}
33
34
	/**
35
	 * @inheritdoc
36
	 */
37
	protected function action(Request $request)
38
	{
39
		return $this->closure->__invoke(...array_values($request->path_params));
40
	}
41
}
42