OrCriterion::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
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