Completed
Pull Request — master (#42)
by Frederik
02:22
created

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