Passed
Branch master (30bd85)
by Mihail
02:09
created

Arguments::__clone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 0
c 0
b 0
f 0
dl 0
loc 1
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
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 56
    public function __construct(protected array $data = []) {}
37
38
    public function __clone() {}
39
40 2
    public function namespace(
41
        string $prefix,
42
        bool $lowercase = true,
43
        bool $trim = true): static
44
    {
45 2
        return new static(
46 2
            $this->filter($this->toArray(), $prefix, $lowercase, $trim)
47 2
        );
48
    }
49
50 1
    public function toImmutable(): Immutable
51
    {
52 1
        return new Immutable($this->data);
53
    }
54
}
55