Passed
Push — master ( 3436a5...44e82b )
by Akmal
01:09
created

CloneableQueryTrait::withFragment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace OpenEngine\Mika\Core\Components\Http\Message\Uri\Traits;
4
5
trait CloneableQueryTrait
6
{
7
    use QueryTrait;
8
9
    /**
10
     * Return an instance with the specified path.
11
     *
12
     * This method MUST retain the state of the current instance, and return
13
     * an instance that contains the specified path.
14
     *
15
     * The path can either be empty or absolute (starting with a slash) or
16
     * rootless (not starting with a slash). Implementations MUST support all
17
     * three syntaxes.
18
     *
19
     * If the path is intended to be domain-relative rather than path relative then
20
     * it must begin with a slash ("/"). Paths not starting with a slash ("/")
21
     * are assumed to be relative to some base path known to the application or
22
     * consumer.
23
     *
24
     * Users can provide both encoded and decoded path characters.
25
     * Implementations ensure the correct encoding as outlined in getPath().
26
     *
27
     * @param string $path The path to use with the new instance.
28
     * @return static A new instance with the specified path.
29
     * @throws \InvalidArgumentException for invalid paths.
30
     */
31
    public function withPath($path)
32
    {
33
        $clone = clone $this;
34
        return $clone->setPath($path);
35
    }
36
37
    /**
38
     * Return an instance with the specified query string.
39
     *
40
     * This method MUST retain the state of the current instance, and return
41
     * an instance that contains the specified query string.
42
     *
43
     * Users can provide both encoded and decoded query characters.
44
     * Implementations ensure the correct encoding as outlined in getQuery().
45
     *
46
     * An empty query string value is equivalent to removing the query string.
47
     *
48
     * @param string $query The query string to use with the new instance.
49
     * @return static A new instance with the specified query string.
50
     * @throws \InvalidArgumentException for invalid query strings.
51
     */
52
    public function withQuery($query)
53
    {
54
        $clone = clone $this;
55
        return $clone->setQuery($query);
56
    }
57
58
    /**
59
     * Return an instance with the specified URI fragment.
60
     *
61
     * This method MUST retain the state of the current instance, and return
62
     * an instance that contains the specified URI fragment.
63
     *
64
     * Users can provide both encoded and decoded fragment characters.
65
     * Implementations ensure the correct encoding as outlined in getFragment().
66
     *
67
     * An empty fragment value is equivalent to removing the fragment.
68
     *
69
     * @param string $fragment The fragment to use with the new instance.
70
     * @return static A new instance with the specified fragment.
71
     */
72
    public function withFragment($fragment)
73
    {
74
        $clone = clone $this;
75
        return $clone->setFragment($fragment);
76
    }
77
}
78