-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathSlimUriStub.php
More file actions
112 lines (90 loc) · 2.08 KB
/
Copy pathSlimUriStub.php
File metadata and controls
112 lines (90 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
declare (strict_types=1);
namespace PhpMiddlewareTest\PhpDebugBar;
use Psr\Http\Message\UriInterface;
/**
* Mimics Slim 3 Slim\Http\Uri: a PSR-7 URI with an extra getBasePath() method,
* used to cover the duck-typed Slim3 branch of PhpDebugBarMiddleware::extractPath()
* without depending on slim/slim 3. Parameters are untyped on purpose so the
* stub satisfies both psr/http-message ^1.0 and ^2.0.
*/
final class SlimUriStub implements UriInterface
{
/** @var string */
private $basePath;
/** @var string */
private $path;
public function __construct(string $basePath, string $path)
{
$this->basePath = $basePath;
$this->path = $path;
}
public function getBasePath(): string
{
return $this->basePath;
}
public function getScheme(): string
{
return 'http';
}
public function getAuthority(): string
{
return 'example.com';
}
public function getUserInfo(): string
{
return '';
}
public function getHost(): string
{
return 'example.com';
}
public function getPort(): ?int
{
return null;
}
public function getPath(): string
{
return $this->path;
}
public function getQuery(): string
{
return '';
}
public function getFragment(): string
{
return '';
}
public function withScheme($scheme): UriInterface
{
return $this;
}
public function withUserInfo($user, $password = null): UriInterface
{
return $this;
}
public function withHost($host): UriInterface
{
return $this;
}
public function withPort($port): UriInterface
{
return $this;
}
public function withPath($path): UriInterface
{
return $this;
}
public function withQuery($query): UriInterface
{
return $this;
}
public function withFragment($fragment): UriInterface
{
return $this;
}
public function __toString(): string
{
return $this->basePath . $this->path;
}
}