OrCriterion   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
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 31
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
final class OrCriterion implements CriterionInterface
7
{
8
    /**
9
     * @var Query
10
     */
11
    private $query;
12
13
    /**
14
     * OrCriterium constructor.
15
     * @param Query $query
16
     */
17 4
    public function __construct(Query $query)
18
    {
19 4
        if ($query->count() !== 2) {
20 3
            throw new \InvalidArgumentException('OR criterium expects two expressions');
21
        }
22
23 1
        $this->query = $query;
24 1
    }
25
26
    /**
27
     * @return string
28
     */
29 1
    public function __toString(): string
30
    {
31 1
        return \sprintf(
32 1
            '(OR %s)',
33 1
            (string)$this->query
34
        );
35
    }
36
}
37