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

Query   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A with() 0 6 1
A __toString() 0 4 1
A count() 0 4 1
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
}