Completed
Pull Request — master (#42)
by Frederik
04:41
created

CommunicatorCriterion::bcc()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

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
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Protocol\Imap\Request\SearchCriteria;
5
6
/**
7
 * Class CommunicatorCriterion
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 5
    private function __construct(string $name, string $query)
27
    {
28 5
        $this->query = $query;
29 5
        $this->name = $name;
30 5
    }
31
32
    /**
33
     * @return string
34
     */
35 5
    public function __toString(): string
36
    {
37 5
        return $this->name . ' ' . $this->query;
38
    }
39
40
    /**
41
     * @param string $query
42
     * @return CommunicatorCriterion
43
     */
44 2
    public static function to(string $query): self
45
    {
46 2
        return new self('TO', $query);
47
    }
48
49
    /**
50
     * @param string $query
51
     * @return CommunicatorCriterion
52
     */
53 1
    public static function cc(string $query): self
54
    {
55 1
        return new self('CC', $query);
56
    }
57
58
    /**
59
     * @param string $query
60
     * @return CommunicatorCriterion
61
     */
62 1
    public static function bcc(string $query): self
63
    {
64 1
        return new self('BCC', $query);
65
    }
66
67
    /**
68
     * @param string $query
69
     * @return CommunicatorCriterion
70
     */
71 1
    public static function from(string $query): self
72
    {
73 1
        return new self('FROM', $query);
74
    }
75
}