Arguments   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 4
eloc 16
c 3
b 0
f 2
dl 0
loc 29
ccs 7
cts 7
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A namespace() 0 7 1
A __construct() 0 1 1
A toImmutable() 0 3 1
A __clone() 0 1 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
26
#[\AllowDynamicProperties]
27
class Arguments implements Argument,
28
                           TransformsToImmutable,
29
                           NamespaceDataFilter,
30
                           IteratorAggregate,
31
                           Countable,
32
                           JsonSerializable
33
{
34
    use AccessorTrait, MutatorTrait, ArrayDataFilterTrait {
35
        MutatorTrait::__set insteadof AccessorTrait;
36
    }
37
38 53
    public function __construct(protected array $data = []) {}
39
40
    public function __clone() {}
41
42 2
    public function namespace(
43
        string $prefix,
44
        bool $lowercase = true,
45
        bool $trim = true): static
46
    {
47 2
        return new static(
48 2
            $this->filter($this->toArray(), $prefix, $lowercase, $trim)
49 2
        );
50
    }
51
52 1
    public function toImmutable(): Immutable
53
    {
54 1
        return new Immutable($this->data);
55
    }
56
}
57