Passed
Push — master ( d2008b...aa9f10 )
by Atanas
01:54
created

NegateCondition   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A isSatisfied() 0 3 1
A getArguments() 0 3 1
1
<?php
2
3
namespace WPEmerge\Routing\Conditions;
4
5
use WPEmerge\Requests\Request;
6
7
/**
8
 * Negate another condition's result.
9
 *
10
 * @codeCoverageIgnore
11
 */
12
class NegateCondition implements ConditionInterface {
13
	/**
14
	 * Condition to negate.
15
	 *
16
	 * @var ConditionInterface
17
	 */
18
	protected $condition = [];
19
20
	/**
21
	 * Constructor.
22
	 *
23
	 * @param mixed $condition
24
	 */
25
	public function __construct( $condition ) {
26
		if ( is_a( $condition, ConditionInterface::class ) ) {
27
			$this->condition = $condition;
28
		} else {
29
			$this->condition = call_user_func( [ConditionFactory::class, 'make'], func_get_args() );
30
		}
31
	}
32
33
	/**
34
	 * {@inheritDoc}
35
	 */
36
	public function isSatisfied( Request $request ) {
37
		return ! $this->condition->isSatisfied( $request );
38
	}
39
40
	/**
41
	 * {@inheritDoc}
42
	 */
43
	public function getArguments( Request $request ) {
44
		return $this->condition->getArguments( $request );
45
	}
46
}
47