-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathURLReadOnly.php
More file actions
141 lines (116 loc) · 3.01 KB
/
URLReadOnly.php
File metadata and controls
141 lines (116 loc) · 3.01 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
namespace MaxieSystems;
/**
* Parse URLs
*
* @property-read string $scheme
* @property-read string|\Stringable $host
* @property-read int|string $port
* @property-read string $user
* @property-read string $pass
* @property-read string|\Stringable $path
* @property-read string|\Stringable $query
* @property-read string $fragment
*/
class URLReadOnly implements URLInterface
{
public function __construct(string|array|object $source, callable $on_create = null, ...$args)
{
$url = new URL($source);
if (null !== $on_create) {
$on_create($url, ...$args);
}
$this->onCreate($url);
$this->url = $url;
}
protected function onCreate(URL $url): void
{
# This method is a hook which can be redefined in the subclasses.
}
final public function isEmpty(string $group = null): bool
{
return $this->url->isEmpty($group);
}
final public function isAbsolute(URLType &$type = null): bool
{
return $this->url->isAbsolute($type);
}
final public function getType(): URLType
{
return $this->url->getType();
}
final public function __unset($name): void
{
throw new \Error(EMessages::readonlyObject($this));
}
final public function __set($name, $value): void
{
throw new \Error(EMessages::readonlyObject($this));
}
public function __isset($name): bool
{
return isset($this->url->$name);
}
public function __get($name): mixed
{
return $this->url->$name;
}
final public function offsetExists(mixed $offset): bool
{
return $this->__isset($offset);
}
final public function offsetGet(mixed $offset): mixed
{
return $this->__get($offset);
}
final public function offsetSet(mixed $offset, mixed $value): void
{
$this->__set($offset, $value);
}
final public function offsetUnset(mixed $offset): void
{
$this->__unset($offset);
}
public function current(): mixed
{
return $this->url->current();
}
final public function next(): void
{
$this->url->next();
}
#[\ReturnTypeWillChange]
final public function key(): string
{
return $this->url->key();
}
final public function valid(): bool
{
return $this->url->valid();
}
final public function rewind(): void
{
$this->url->rewind();
}
final public function __toString()
{
return $this->url->__toString();
}
public function __clone()
{
$this->url = clone $this->url;
}
public function __debugInfo(): array
{
return $this->url->__debugInfo();
}
final public function toStdClass(callable $callback = null, ...$args): \stdClass
{
return $this->url->toStdClass($callback);
}
final public function toArray(callable $callback = null, ...$args): array
{
return $this->url->toArray($callback);
}
private readonly URL $url;
}