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\FormFieldConditionIterator; |
23
|
|
|
use Mcustiel\Phiremock\Domain\Condition\Conditions\HeaderConditionIterator; |
24
|
|
|
use Mcustiel\Phiremock\Domain\Condition\Conditions\MethodCondition; |
25
|
|
|
use Mcustiel\Phiremock\Domain\Condition\Conditions\UrlCondition; |
26
|
|
|
use Mcustiel\Phiremock\Domain\Options\ScenarioState; |
27
|
|
|
|
28
|
|
|
class Conditions |
29
|
|
|
{ |
30
|
|
|
/** @var MethodCondition|null */ |
31
|
|
|
private $method; |
32
|
|
|
/** @var UrlCondition|null */ |
33
|
|
|
private $url; |
34
|
|
|
/** @var BodyCondition|null */ |
35
|
|
|
private $body; |
36
|
|
|
/** @var HeaderConditionIterator|null */ |
37
|
|
|
private $headers; |
38
|
|
|
/** @var FormFieldConditionIterator|null */ |
39
|
|
|
private $formFields; |
40
|
|
|
/** @var ScenarioState|null */ |
41
|
|
|
private $scenarioState; |
42
|
|
|
|
43
|
8 |
|
public function __construct( |
44
|
|
|
?MethodCondition $method = null, |
45
|
|
|
?UrlCondition $url = null, |
46
|
|
|
?BodyCondition $body = null, |
47
|
|
|
?HeaderConditionIterator $headers = null, |
48
|
|
|
?FormFieldConditionIterator $formFields = null, |
49
|
|
|
?ScenarioState $scenarioState = null |
50
|
|
|
) { |
51
|
8 |
|
$this->method = $method; |
52
|
8 |
|
$this->url = $url; |
53
|
8 |
|
$this->body = $body; |
54
|
8 |
|
$this->headers = $headers; |
55
|
8 |
|
$this->formFields = $formFields; |
56
|
8 |
|
$this->scenarioState = $scenarioState; |
57
|
8 |
|
} |
58
|
|
|
|
59
|
|
|
public function hasMethod(): bool |
60
|
|
|
{ |
61
|
|
|
return null !== $this->method; |
62
|
|
|
} |
63
|
|
|
|
64
|
8 |
|
public function getMethod(): ?MethodCondition |
65
|
|
|
{ |
66
|
8 |
|
return $this->method; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function hasUrl(): bool |
70
|
|
|
{ |
71
|
|
|
return null !== $this->url; |
72
|
|
|
} |
73
|
|
|
|
74
|
8 |
|
public function getUrl(): ?UrlCondition |
75
|
|
|
{ |
76
|
8 |
|
return $this->url; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function hasBody(): bool |
80
|
|
|
{ |
81
|
|
|
return null !== $this->body; |
82
|
|
|
} |
83
|
|
|
|
84
|
8 |
|
public function getBody(): ?BodyCondition |
85
|
|
|
{ |
86
|
8 |
|
return $this->body; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function hasHeaders(): bool |
90
|
|
|
{ |
91
|
|
|
return null !== $this->headers && !$this->headers->isEmpty(); |
92
|
|
|
} |
93
|
|
|
|
94
|
8 |
|
public function getHeaders(): ?HeaderConditionIterator |
95
|
|
|
{ |
96
|
8 |
|
return $this->headers; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function hasFormFields(): bool |
100
|
|
|
{ |
101
|
|
|
return null !== $this->formFields && !$this->formFields->isEmpty(); |
102
|
|
|
} |
103
|
|
|
|
104
|
8 |
|
public function getFormFields(): ?FormFieldConditionIterator |
105
|
|
|
{ |
106
|
8 |
|
return $this->formFields; |
107
|
|
|
} |
108
|
|
|
|
109
|
8 |
|
public function hasScenarioState(): bool |
110
|
|
|
{ |
111
|
8 |
|
return $this->scenarioState !== null; |
112
|
|
|
} |
113
|
|
|
|
114
|
2 |
|
public function getScenarioState(): ?ScenarioState |
115
|
|
|
{ |
116
|
2 |
|
return $this->scenarioState; |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|