Completed
Push — master ( 204760...d7809c )
by Sebastian
02:32
created

Request::withMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 2
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Linna Psr7.
5
 *
6
 * @author Sebastian Rapetti <[email protected]>
7
 * @copyright (c) 2018, Sebastian Rapetti
8
 * @license http://opensource.org/licenses/MIT MIT License
9
 */
10
declare(strict_types=1);
11
12
namespace Linna\Psr7;
13
14
use Linna\Psr7\Message;
15
use Psr\Http\Message\RequestInterface;
16
use Psr\Http\Message\UriInterface;
17
18
/**
19
 * HTTP Psr7 Request implementation.
20
 */
21
class Request extends Message implements RequestInterface
22
{
23
    /**
24
     * Retrieves the message's request target.
25
     *
26
     * Retrieves the message's request-target either as it will appear (for
27
     * clients), as it appeared at request (for servers), or as it was
28
     * specified for the instance (see withRequestTarget()).
29
     *
30
     * In most cases, this will be the origin-form of the composed URI,
31
     * unless a value was provided to the concrete implementation (see
32
     * withRequestTarget() below).
33
     *
34
     * If no URI is available, and no request-target has been specifically
35
     * provided, this method MUST return the string "/".
36
     *
37
     * @return string
38
     */
39
    public function getRequestTarget() : string
40
    {
41
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return string. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
42
43
    /**
44
     * Return an instance with the specific request-target.
45
     *
46
     * If the request needs a non-origin-form request-target — e.g., for
47
     * specifying an absolute-form, authority-form, or asterisk-form —
48
     * this method may be used to create an instance with the specified
49
     * request-target, verbatim.
50
     *
51
     * This method MUST be implemented in such a way as to retain the
52
     * immutability of the message, and MUST return an instance that has the
53
     * changed request target.
54
     *
55
     * @link http://tools.ietf.org/html/rfc7230#section-5.3 (for the various
56
     *     request-target forms allowed in request messages)
57
     * @param mixed $requestTarget
58
     * @return static
59
     */
60
    public function withRequestTarget(string $requestTarget) : RequestInterface
61
    {
62
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Psr\Http\Message\RequestInterface. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
63
64
    /**
65
     * Retrieves the HTTP method of the request.
66
     *
67
     * @return string Returns the request method.
68
     */
69
    public function getMethod() : string
70
    {
71
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return string. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
72
73
    /**
74
     * Return an instance with the provided HTTP method.
75
     *
76
     * While HTTP method names are typically all uppercase characters, HTTP
77
     * method names are case-sensitive and thus implementations SHOULD NOT
78
     * modify the given string.
79
     *
80
     * This method MUST be implemented in such a way as to retain the
81
     * immutability of the message, and MUST return an instance that has the
82
     * changed request method.
83
     *
84
     * @param string $method Case-sensitive method.
85
     * @return static
86
     * @throws \InvalidArgumentException for invalid HTTP methods.
87
     */
88
    public function withMethod(string $method) : RequestInterface
89
    {
90
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Psr\Http\Message\RequestInterface. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
91
92
    /**
93
     * Retrieves the URI instance.
94
     *
95
     * This method MUST return a UriInterface instance.
96
     *
97
     * @link http://tools.ietf.org/html/rfc3986#section-4.3
98
     * @return UriInterface Returns a UriInterface instance
99
     *     representing the URI of the request.
100
     */
101
    public function getUri() : UriInterface
102
    {
103
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Psr\Http\Message\UriInterface. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
104
105
    /**
106
     * Returns an instance with the provided URI.
107
     *
108
     * This method MUST update the Host header of the returned request by
109
     * default if the URI contains a host component. If the URI does not
110
     * contain a host component, any pre-existing Host header MUST be carried
111
     * over to the returned request.
112
     *
113
     * You can opt-in to preserving the original state of the Host header by
114
     * setting `$preserveHost` to `true`. When `$preserveHost` is set to
115
     * `true`, this method interacts with the Host header in the following ways:
116
     *
117
     * - If the Host header is missing or empty, and the new URI contains
118
     *   a host component, this method MUST update the Host header in the returned
119
     *   request.
120
     * - If the Host header is missing or empty, and the new URI does not contain a
121
     *   host component, this method MUST NOT update the Host header in the returned
122
     *   request.
123
     * - If a Host header is present and non-empty, this method MUST NOT update
124
     *   the Host header in the returned request.
125
     *
126
     * This method MUST be implemented in such a way as to retain the
127
     * immutability of the message, and MUST return an instance that has the
128
     * new UriInterface instance.
129
     *
130
     * @link http://tools.ietf.org/html/rfc3986#section-4.3
131
     * @param UriInterface $uri New request URI to use.
132
     * @param bool $preserveHost Preserve the original state of the Host header.
133
     * @return static
134
     */
135
    public function withUri(UriInterface $uri, bool $preserveHost = false) : RequestInterface
136
    {
137
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Psr\Http\Message\RequestInterface. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
138
}
139