Passed
Push — master ( 054262...aa672f )
by Mariano
04:25
created

on()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
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\Client;
20
21
use Mcustiel\Phiremock\Client\Utils\A;
22
use Mcustiel\Phiremock\Client\Utils\ConditionsBuilder;
23
use Mcustiel\Phiremock\Client\Utils\ExpectationBuilder;
24
use Mcustiel\Phiremock\Client\Utils\HttpResponseBuilder;
25
use Mcustiel\Phiremock\Client\Utils\Is;
26
use Mcustiel\Phiremock\Client\Utils\Proxy;
27
use Mcustiel\Phiremock\Client\Utils\ProxyResponseBuilder;
28
use Mcustiel\Phiremock\Client\Utils\Respond;
29
use Mcustiel\Phiremock\Domain\Condition\Matchers\CaseInsensitiveEquals;
30
use Mcustiel\Phiremock\Domain\Condition\Matchers\Contains;
31
use Mcustiel\Phiremock\Domain\Condition\Matchers\Equals;
32
use Mcustiel\Phiremock\Domain\Condition\Matchers\JsonEquals;
33
use Mcustiel\Phiremock\Domain\Condition\Matchers\RegExp;
34
35
// ConditionBuilder creators
36
37
function request(): ConditionsBuilder
38
{
39
    return new ConditionsBuilder();
40
}
41
42
function getRequest(): ConditionsBuilder
43
{
44
    return A::getRequest();
45
}
46
47
function postRequest(): ConditionsBuilder
48
{
49
    return A::postRequest();
50
}
51
52
function putRequest(): ConditionsBuilder
53
{
54
    return A::putRequest();
55
}
56
57
function deleteRequest(): ConditionsBuilder
58
{
59
    return A::deleteRequest();
60
}
61
62
function patchRequest(): ConditionsBuilder
63
{
64
    return A::patchRequest();
65
}
66
67
function headRequest(): ConditionsBuilder
68
{
69
    return A::headRequest();
70
}
71
72
function optionsRequest(): ConditionsBuilder
73
{
74
    return A::optionsRequest();
75
}
76
77
function fetchRequest(): ConditionsBuilder
78
{
79
    return A::fetchRequest();
80
}
81
82
function linkRequest(): ConditionsBuilder
83
{
84
    return A::linkRequest();
85
}
86
87
// Matcher creators
88
89
function isEqualTo($value): Equals
90
{
91
    return Is::equalTo($value);
92
}
93
94
function isSameStringAs(string $value): CaseInsensitiveEquals
95
{
96
    return Is::sameStringAs($value);
97
}
98
99
function matchesRegex(string $value): RegExp
100
{
101
    return Is::matching($value);
102
}
103
104
function isSameJsonAs($value): JsonEquals
105
{
106
    return Is::sameJsonObjectAs($value);
107
}
108
109
function contains(string $value): Contains
110
{
111
    return Is::containing($value);
112
}
113
114
// ResponseBuilder creators
115
116
function respond(int $statusCode): HttpResponseBuilder
117
{
118
    return Respond::withStatusCode($statusCode);
119
}
120
121
function proxyTo(string $url): ProxyResponseBuilder
122
{
123
    return Proxy::to($url);
124
}
125
126
// ExpectationBuilder creator
127
128
function on(ConditionsBuilder $builder): ExpectationBuilder
129
{
130
    return Phiremock::on($builder);
131
}
132