Action::setMethod()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
/*
6
 * This file is part of the FiveLab Resource package
7
 *
8
 * (c) FiveLab
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code
12
 */
13
14
namespace FiveLab\Component\Resource\Resource\Action;
15
16
use FiveLab\Component\Resource\Resource\Href\HrefInterface;
17
18
/**
19
 * The default action of resource.
20
 *
21
 * @author Vitaliy Zhuk <[email protected]>
22
 */
23
class Action implements ActionInterface
24
{
25
    /**
26
     * @var string
27
     */
28
    private $name;
29
30
    /**
31
     * @var HrefInterface
32
     */
33
    private $href;
34
35
    /**
36
     * @var Method
37
     */
38
    private $method;
39
40
    /**
41
     * @var array
42
     */
43
    private $attributes;
44
45
    /**
46
     * Constructor.
47
     *
48
     * @param string        $name
49
     * @param HrefInterface $href
50
     * @param Method        $method
51
     * @param array         $attributes
52
     */
53 6
    public function __construct(string $name, HrefInterface $href, Method $method, array $attributes = [])
54
    {
55 6
        $this->name = $name;
56 6
        $this->href = $href;
57 6
        $this->method = $method;
58 6
        $this->attributes = $attributes;
59 6
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64 2
    public function getName(): string
65
    {
66 2
        return $this->name;
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72 3
    public function getHref(): HrefInterface
73
    {
74 3
        return $this->href;
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80 1
    public function setHref(HrefInterface $href): void
81
    {
82 1
        $this->href = $href;
83 1
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88 2
    public function getMethod(): Method
89
    {
90 2
        return $this->method;
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96 1
    public function setMethod(Method $method): void
97
    {
98 1
        $this->method = $method;
99 1
    }
100
101
    /**
102
     * {@inheritdoc}
103
     */
104 3
    public function getAttributes(): array
105
    {
106 3
        return $this->attributes;
107
    }
108
109
    /**
110
     * {@inheritdoc}
111
     */
112 1
    public function setAttributes(array $attributes): void
113
    {
114 1
        $this->attributes = $attributes;
115 1
    }
116
}
117