NotDecorator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 42.86%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 30
ccs 3
cts 7
cp 0.4286
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A useWith() 0 8 2
A decorate() 0 12 1
1
<?php
2
3
/**
4
 * This software package is licensed under `AGPL-3.0-only, proprietary` license[s].
5
 *
6
 * @package maslosoft/manganel
7
 * @license AGPL-3.0-only, proprietary
8
 *
9
 * @copyright Copyright (c) Peter Maselkowski <[email protected]>
10
 * @link https://maslosoft.com/manganel/
11
 */
12
13
namespace Maslosoft\Manganel\Decorators\QueryBuilder\Operators;
14
15
16
use Maslosoft\Manganel\Interfaces\QueryBuilder\OperatorDecoratorInterface;
17
18
class NotDecorator implements OperatorDecoratorInterface
19
{
20
21
	/**
22
	 * Whether to use this operator with current key
23
	 * @param string $key
24
	 * @param mixed $value
25
	 */
26 3
	public function useWith($key, $value)
27
	{
28 3
		if (!is_array($value))
29
		{
30 3
			return false;
31
		}
32
		return array_key_exists('$ne', $value);
33
	}
34
35
	public function decorate(&$condition, $name, $value)
36
	{
37
		$condition = [
38
			'bool' => [
39
				'must_not' => [
40
					'term' => [
41
						$name => $value['$ne']
42
					]
43
				]
44
			]
45
		];
46
	}
47
}