/
SizeValue.php
110 lines (97 loc) · 1.94 KB
/
SizeValue.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
namespace Concrete\Core\StyleCustomizer\Style\Value;
class SizeValue extends Value
{
/**
* The numeric amount of the size.
*
* @var mixed
*/
protected $size;
/**
* The unit of the size.
*
* @var string
*/
protected $unit = 'px';
/**
* Set the numeric amount of the size.
*
* @param mixed $size
*
* @return $this
*/
public function setSize($size)
{
$this->size = $size;
return $this;
}
/**
* Set the unit of the size.
*
* @param string $unit
*
* @return $this
*/
public function setUnit($unit)
{
$this->unit = (string) $unit;
return $this;
}
/**
* Get the numeric amount of the size.
*
* @return mixed
*/
public function getSize()
{
return $this->size;
}
/**
* Get the unit of the size.
*
* @return string
*/
public function getUnit()
{
return $this->unit;
}
/**
* @deprecated Use getUnit()
*
* @return string
*
* @see \Concrete\Core\StyleCustomizer\Style\Value\SizeValue::getUnit()
*/
public function getUnits()
{
return $this->getUnit();
}
/**
* Does this value has the numeric amount of the size?
*
* @return bool
*/
public function hasSize()
{
return (string) $this->getSize() !== '';
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\StyleCustomizer\Style\Value\Value::toStyleString()
*/
public function toStyleString()
{
return $this->hasSize() ? $this->getSize() . $this->getUnit() : '';
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\StyleCustomizer\Style\Value\Value::toLessVariablesArray()
*/
public function toLessVariablesArray()
{
return [$this->getVariable() . '-size' => $this->toStyleString()];
}
}