-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAbstractInputData.php
More file actions
46 lines (38 loc) · 1.15 KB
/
AbstractInputData.php
File metadata and controls
46 lines (38 loc) · 1.15 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
<?php
namespace GT\Input\InputData;
use ArrayAccess;
use Countable;
use GT\Input\InputData\Datum\MultipleInputDatum;
use GT\Input\InputValueGetter;
use Iterator;
use GT\Input\InputData\Datum\InputDatum;
/**
* @implements ArrayAccess<string, string|InputDatum>
* @implements Iterator<string, string|InputDatum>
*/
abstract class AbstractInputData implements ArrayAccess, Countable, Iterator {
use InputValueGetter;
use KeyValueArrayAccess;
use KeyValueCountable;
use KeyValueIterator;
protected QueryStringInputData $queryStringParameters;
protected BodyInputData $bodyParameters;
public function get(string $key):mixed {
return $this->parameters[$key] ?? null;
}
public function contains(string $key):bool {
return isset($this->parameters[$key]);
}
public function hasValue(string $key):bool {
$value = $this->parameters[$key] ?? "";
return (strlen((string)$value) > 0);
}
protected function set(string $key, InputDatum $value):void {
$this->parameters[$key] = (string)$value;
}
public function withKeyValue(string $key, InputDatum $value):static {
$clone = clone($this);
$clone->parameters[$key] = (string)$value;
return $clone;
}
}