CommunicatorCriterion::to()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Protocol\Imap\Request\SearchCriteria;
5
6
final class CommunicatorCriterion implements CriterionInterface
7
{
8
    /**
9
     * @var string
10
     */
11
    private $name;
12
13
    /**
14
     * @var string
15
     */
16
    private $query;
17
18
    /**
19
     * @param string $name
20
     * @param string $query
21
     */
22 5
    private function __construct(string $name, string $query)
23
    {
24 5
        $this->query = $query;
25 5
        $this->name = $name;
26 5
    }
27
28
    /**
29
     * @return string
30
     */
31 5
    public function __toString(): string
32
    {
33 5
        return $this->name . ' ' . $this->query;
34
    }
35
36
    /**
37
     * @param string $query
38
     * @return CommunicatorCriterion
39
     */
40 2
    public static function to(string $query): self
41
    {
42 2
        return new self('TO', $query);
43
    }
44
45
    /**
46
     * @param string $query
47
     * @return CommunicatorCriterion
48
     */
49 1
    public static function cc(string $query): self
50
    {
51 1
        return new self('CC', $query);
52
    }
53
54
    /**
55
     * @param string $query
56
     * @return CommunicatorCriterion
57
     */
58 1
    public static function bcc(string $query): self
59
    {
60 1
        return new self('BCC', $query);
61
    }
62
63
    /**
64
     * @param string $query
65
     * @return CommunicatorCriterion
66
     */
67 1
    public static function from(string $query): self
68
    {
69 1
        return new self('FROM', $query);
70
    }
71
}
72