Variant   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 19
c 0
b 0
f 0
dl 0
loc 66
ccs 19
cts 19
cp 1
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 7 1
A path() 0 3 1
A withUrl() 0 6 1
A name() 0 3 1
A hasOperations() 0 3 1
A withPath() 0 6 1
1
<?php
2
3
/**
4
 * Copyright (c) Florian Krämer (https://florian-kraemer.net)
5
 * Licensed under The MIT License
6
 * For full copyright and license information, please see the LICENSE.txt
7
 * Redistributions of files must retain the above copyright notice.
8
 *
9
 * @copyright Copyright (c) Florian Krämer (https://florian-kraemer.net)
10
 * @author    Florian Krämer
11
 * @link      https://github.com/Phauthentic
12
 * @license   https://opensource.org/licenses/MIT MIT License
13
 */
14
15
declare(strict_types=1);
16
17
namespace Phauthentic\Infrastructure\Storage\Processor;
18
19
/**
20
 * Manipulation
21
 */
22
class Variant implements VariantInterface
23
{
24
    protected string $name = '';
25
    protected array $operations = [];
26
    protected string $path = '';
27
    protected string $url = '';
28
29
    /**
30
     * @return array
31
     */
32 1
    public function toArray(): array
33
    {
34
        return [
35 1
            'name' => $this->name,
36 1
            'operations' => $this->operations,
37 1
            'path' => $this->path,
38 1
            'url' => $this->url,
39
        ];
40
    }
41
42
    /**
43
     * @return string
44
     */
45 2
    public function name(): string
46
    {
47 2
        return $this->name;
48
    }
49
50
    /**
51
     * @return string
52
     */
53 1
    public function path(): string
54
    {
55 1
        return $this->path;
56
    }
57
58
    /**
59
     * @return bool
60
     */
61 1
    public function hasOperations(): bool
62
    {
63 1
        return count($this->operations) > 0;
64
    }
65
66
    /**
67
     * @param string $url Path
68
     * @return self
69
     */
70 1
    public function withUrl(string $url): self
71
    {
72 1
        $that = clone $this;
73 1
        $that->url = $url;
74
75 1
        return $that;
76
    }
77
78
    /**
79
     * @param string $path Path
80
     * @return self
81
     */
82 1
    public function withPath(string $path): self
83
    {
84 1
        $that = clone $this;
85 1
        $that->path = $path;
86
87 1
        return $that;
88
    }
89
}
90