Passed
Push — master ( 700796...a34856 )
by Mariano
01:12
created

Conditions::hasHeaders()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of Phiremock.
4
 *
5
 * Phiremock is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Lesser General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * Phiremock is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with Phiremock.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
namespace Mcustiel\Phiremock\Domain;
20
21
use Mcustiel\Phiremock\Domain\Condition\Conditions\BodyCondition;
22
use Mcustiel\Phiremock\Domain\Condition\Conditions\HeaderConditionIterator;
23
use Mcustiel\Phiremock\Domain\Condition\Conditions\MethodCondition;
24
use Mcustiel\Phiremock\Domain\Condition\Conditions\UrlCondition;
25
use Mcustiel\Phiremock\Domain\Options\ScenarioState;
26
27
class Conditions
28
{
29
    /** @var MethodCondition|null */
30
    private $method;
31
    /** @var UrlCondition|null */
32
    private $url;
33
    /** @var BodyCondition|null */
34
    private $body;
35
    /** @var HeaderConditionIterator|null */
36
    private $headers;
37
    /** @var ScenarioState|null */
38
    private $scenarioState;
39
40
    public function __construct(
41
        ?MethodCondition $method = null,
42
        ?UrlCondition $url = null,
43
        ?BodyCondition $body = null,
44
        ?HeaderConditionIterator $headers = null,
45
        ?ScenarioState $scenarioState = null
46
    ) {
47
        $this->method = $method;
48
        $this->url = $url;
49
        $this->body = $body;
50
        $this->headers = $headers;
51
        $this->scenarioState = $scenarioState;
52
    }
53
54
    public function hasMethod(): bool
55
    {
56
        return null !== $this->method;
57
    }
58
59
    public function getMethod(): ?MethodCondition
60
    {
61
        return $this->method;
62
    }
63
64
    public function hasUrl(): bool
65
    {
66
        return null !== $this->url;
67
    }
68
69
    public function getUrl(): ?UrlCondition
70
    {
71
        return $this->url;
72
    }
73
74
    public function hasBody(): bool
75
    {
76
        return null !== $this->body;
77
    }
78
79
    public function getBody(): ?BodyCondition
80
    {
81
        return $this->body;
82
    }
83
84
    public function hasHeaders(): bool
85
    {
86
        return null !== $this->headers && !$this->headers->isEmpty();
87
    }
88
89
    public function getHeaders(): ?HeaderConditionIterator
90
    {
91
        return $this->headers;
92
    }
93
94
    public function hasScenarioState(): bool
95
    {
96
        return $this->scenarioState !== null;
97
    }
98
99
    public function getScenarioState(): ?ScenarioState
100
    {
101
        return $this->scenarioState;
102
    }
103
}
104