CommunicatorCriterion   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __toString() 0 4 1
A to() 0 4 1
A cc() 0 4 1
A bcc() 0 4 1
A from() 0 4 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