OrCriterion::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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