Passed
Push — master ( 5d9eaa...8dfc1c )
by Mihail
12:13
created

Arguments::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Koded package.
5
 *
6
 * (c) Mihail Binev <[email protected]>
7
 *
8
 * Please view the LICENSE distributed with this source code
9
 * for the full copyright and license information.
10
 */
11
12
namespace Koded\Stdlib;
13
14
use Countable;
15
use IteratorAggregate;
16
use JsonSerializable;
17
18
/**
19
 * Arguments is a MUTABLE, multipurpose class that encapsulates data.
20
 * It is useful for passing it around as a DTO.
21
 *
22
 * TIP: Avoid creating a child classes with properties from this one.
23
 * It will mess up your Zen.
24
 */
25
class Arguments implements Argument,
26
                           TransformsToImmutable,
27
                           NamespaceDataFilter,
28
                           IteratorAggregate,
29
                           Countable,
30
                           JsonSerializable
31
{
32
    use AccessorTrait, MutatorTrait, ArrayDataFilterTrait {
33
        MutatorTrait::__set insteadof AccessorTrait;
34
    }
35
36
    protected array $storage = [];
37
38 56
    public function __construct(array $values = [])
39
    {
40 56
        $this->storage = $values;
41
    }
42
43
    public function __clone()
44
    {
45
    }
46
47 2
    public function namespace(
48
        string $prefix,
49
        bool $lowercase = true,
50
        bool $trim = true): static
51
    {
52 2
        return new static($this->filter($this->toArray(), $prefix, $lowercase, $trim));
53
    }
54
55 1
    public function toImmutable(): Immutable
56
    {
57 1
        return new Immutable($this->storage);
58
    }
59
}
60