-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArguments.php
More file actions
56 lines (47 loc) · 1.36 KB
/
Arguments.php
File metadata and controls
56 lines (47 loc) · 1.36 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
<?php
/*
* This file is part of the Koded package.
*
* (c) Mihail Binev <mihail@kodeart.com>
*
* Please view the LICENSE distributed with this source code
* for the full copyright and license information.
*/
namespace Koded\Stdlib;
use Countable;
use IteratorAggregate;
use JsonSerializable;
/**
* Arguments is a MUTABLE, multipurpose class that encapsulates data.
* It is useful for passing it around as a DTO.
*
* TIP: Avoid creating a child classes with properties from this one.
* It will mess up your Zen.
*/
#[\AllowDynamicProperties]
class Arguments implements Argument,
TransformsToImmutable,
NamespaceDataFilter,
IteratorAggregate,
Countable,
JsonSerializable
{
use AccessorTrait, MutatorTrait, ArrayDataFilterTrait {
MutatorTrait::__set insteadof AccessorTrait;
}
public function __construct(protected array $data = []) {}
public function __clone() {}
public function namespace(
string $prefix,
bool $lowercase = true,
bool $trim = true): static
{
return new static(
$this->filter($this->toArray(), $prefix, $lowercase, $trim)
);
}
public function toImmutable(): Immutable
{
return new Immutable($this->data);
}
}