Completed
Pull Request — master (#42)
by Frederik
02:26
created

NotCriterion   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 32
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A __toString() 0 7 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Protocol\Imap\Request\SearchCriteria;
5
6
/**
7
 * Class NotCriterion
8
 * @package Genkgo\Mail\Protocol\Imap\Request\SearchCriteria
9
 */
10
final class NotCriterion implements CriterionInterface
11
{
12
13
    /**
14
     * @var Query
15
     */
16
    private $query;
17
18
    /**
19
     * OrCriterium constructor.
20
     * @param Query $query
21
     */
22 2
    public function __construct(Query $query)
23
    {
24 2
        if ($query->count() === 0) {
25 1
            throw new \InvalidArgumentException('NOT criterium expects query with at least one expression');
26
        }
27
28 1
        $this->query = $query;
29 1
    }
30
31
    /**
32
     * @return string
33
     */
34 1
    public function __toString(): string
35
    {
36 1
        return sprintf(
37 1
            '(NOT %s)',
38 1
            (string)$this->query
39
        );
40
    }
41
}