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

NegateCondition::isSatisfied()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 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