Passed
Push — developer ( 6b5868...bed0f9 )
by Radosław
22:42 queued 03:39
created

FormField   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 13
c 1
b 0
f 0
dl 0
loc 95
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getLabel() 0 3 1
A addAttribute() 0 3 1
A getName() 0 3 1
A getAttributes() 0 3 1
A getType() 0 3 1
1
<?php
2
/**
3
 * YetiForce shop form field file.
4
 *
5
 * @package App
6
 *
7
 * @copyright YetiForce S.A.
8
 * @license   YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
9
 * @author    Klaudia Łozowska <[email protected]>
10
 */
11
12
namespace App\YetiForce\Shop;
13
14
/**
15
 * YetiForce shop form field class.
16
 */
17
class FormField
18
{
19
	/**
20
	 * Name
21
	 *
22
	 * @var string
23
	 */
24
	private string $name;
25
26
	/**
27
	 * Label
28
	 *
29
	 * @var ?string
30
	 */
31
	private ?string $label;
32
33
	/**
34
	 * Type
35
	 *
36
	 * @var string
37
	 */
38
	private string $type;
39
40
	/**
41
	 * Field attributes
42
	 *
43
	 * @var array
44
	 */
45
	private array $attributes = [];
46
47
	/**
48
	 * Construct
49
	 *
50
	 * @param string $name
51
	 * @param ?string $label
52
	 * @param string $type
53
	 */
54
	public function __construct(string $name, ?string $label, string $type)
55
	{
56
		$this->name = $name;
57
		$this->label = $label;
58
		$this->type = $type;
59
	}
60
61
	/**
62
	 * Get name
63
	 *
64
	 * @return string
65
	 */
66
	public function getName(): string
67
	{
68
		return $this->name;
69
	}
70
71
	/**
72
	 * Get label
73
	 *
74
	 * @return ?string
75
	 */
76
	public function getLabel(): ?string
77
	{
78
		return $this->label;
79
	}
80
81
	/**
82
	 * Get type
83
	 *
84
	 * @return string
85
	 */
86
	public function getType(): string
87
	{
88
		return $this->type;
89
	}
90
91
	/**
92
	 * Get field attributes
93
	 *
94
	 * @return array
95
	 */
96
	public function getAttributes(): array
97
	{
98
		return $this->attributes;
99
	}
100
101
	/**
102
	 * Add field attribute
103
	 *
104
	 * @param string $name
105
	 * @param string $value
106
	 *
107
	 * @return void
108
	 */
109
	public function addAttribute(string $name, string $value): void
110
	{
111
		$this->attributes[$name] = $value;
112
	}
113
}
114