Passed
Push — master ( 27c065...381e9f )
by Atanas
01:52
created

Multiple   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 45
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A satisfied() 0 8 3
A getArguments() 0 3 1
A getConditions() 0 3 1
1
<?php
2
3
namespace Obsidian\Routing\Conditions;
4
5
use Obsidian\Request;
6
7
/**
8
 * Check against a custom callable
9
 */
10
class Multiple implements ConditionInterface {
11
	/**
12
	 * Array of conditions to check
13
	 *
14
	 * @var array<ConditionInterface>
15
	 */
16
	protected $conditions = [];
17
18
	/**
19
	 * Constructor
20
	 *
21
	 * @param array $conditions
22
	 */
23 1
	public function __construct( $conditions ) {
24 1
		$this->conditions = array_map( [Factory::class, 'make'], $conditions );
25 1
	}
26
27
	/**
28
	 * {@inheritDoc}
29
	 */
30 1
	public function satisfied( Request $request ) {
31 1
		foreach ( $this->conditions as $condition ) {
32 1
			if ( ! $condition->satisfied( $request ) ) {
33 1
				return false;
34
			}
35
		}
36 1
		return true;
37
	}
38
39
	/**
40
	 * {@inheritDoc}
41
	 */
42 1
	public function getArguments( Request $request ) {
43 1
		return [];
44
	}
45
46
	/**
47
	 * Get all assigned conditions
48
	 *
49
	 * @return \Obsidian\Routing\Conditions\ConditionInterface[]
50
	 */
51 1
	public function getConditions() {
52 1
		return $this->conditions;
53
	}
54
}
55