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

SizeCriterion   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 48
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __toString() 0 4 1
A smaller() 0 4 1
A larger() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Protocol\Imap\Request\SearchCriteria;
5
6
/**
7
 * Class SizeCriterium
8
 * @package Genkgo\Mail\Protocol\Imap\Request\SearchCriteria
9
 */
10
final class SizeCriterion implements CriterionInterface
11
{
12
    /**
13
     * @var string
14
     */
15
    private $name;
16
    /**
17
     * @var int
18
     */
19
    private $size;
20
21
    /**
22
     * SizeCriterium constructor.
23
     * @param string $name
24
     * @param int $size
25
     */
26 3
    private function __construct(string $name, int $size)
27
    {
28 3
        $this->name = $name;
29 3
        $this->size = $size;
30 3
    }
31
32
    /**
33
     * @return string
34
     */
35 3
    public function __toString(): string
36
    {
37 3
        return sprintf('%s %s', $this->name, $this->size);
38
    }
39
40
    /**
41
     * @param int $size
42
     * @return SizeCriterion
43
     */
44 1
    public static function smaller(int $size): self
45
    {
46 1
        return new self('SMALLER', $size);
47
    }
48
49
    /**
50
     * @param int $size
51
     * @return SizeCriterion
52
     */
53 2
    public static function larger(int $size): self
54
    {
55 2
        return new self('LARGER', $size);
56
    }
57
}