Completed
Pull Request — master (#42)
by Frederik
01:50
created

Query::count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Protocol\Imap\Request\SearchCriteria;
5
6
/**
7
 * Class SearchCriteria
8
 * @package Genkgo\Mail\Protocol\Imap
9
 */
10
final class Query implements \Countable
11
{
12
    /**
13
     * @var array
14
     */
15
    private $criteria = [];
16
17
    /**
18
     * @param CriterionInterface $criterion
19
     * @return Query
20
     */
21
    public function with(CriterionInterface $criterion): self
22
    {
23
        $clone = clone $this;
24
        $clone->criteria[] = $criterion;
25
        return $clone;
26
    }
27
28
    /**
29
     * @return string
30
     */
31
    public function __toString(): string
32
    {
33
        return trim(implode(' ', $this->criteria));
34
    }
35
36
    /**
37
     * @return int
38
     */
39
    public function count()
40
    {
41
        return count($this->criteria);
42
    }
43
}