Skip to content

Commit 1d2d5f3

Browse files
authored
[CLEANUP] Avoid Hungarian notation for unit and sizeUnits (#1088)
Part of #756
1 parent 1ffafd9 commit 1d2d5f3

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/Value/Size.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Size extends PrimitiveValue
6060
/**
6161
* @var string|null
6262
*/
63-
private $sUnit;
63+
private $unit;
6464

6565
/**
6666
* @var bool
@@ -69,15 +69,15 @@ class Size extends PrimitiveValue
6969

7070
/**
7171
* @param float|int|string $size
72-
* @param string|null $sUnit
72+
* @param string|null $unit
7373
* @param bool $bIsColorComponent
7474
* @param int<0, max> $lineNumber
7575
*/
76-
public function __construct($size, $sUnit = null, $bIsColorComponent = false, $lineNumber = 0)
76+
public function __construct($size, $unit = null, $bIsColorComponent = false, $lineNumber = 0)
7777
{
7878
parent::__construct($lineNumber);
7979
$this->size = (float) $size;
80-
$this->sUnit = $sUnit;
80+
$this->unit = $unit;
8181
$this->bIsColorComponent = $bIsColorComponent;
8282
}
8383

@@ -110,18 +110,18 @@ public static function parse(ParserState $parserState, $bIsColorComponent = fals
110110
}
111111
}
112112

113-
$sUnit = null;
114-
$aSizeUnits = self::getSizeUnits();
115-
foreach ($aSizeUnits as $length => &$aValues) {
113+
$unit = null;
114+
$sizeUnits = self::getSizeUnits();
115+
foreach ($sizeUnits as $length => &$aValues) {
116116
$sKey = \strtolower($parserState->peek($length));
117117
if (\array_key_exists($sKey, $aValues)) {
118-
if (($sUnit = $aValues[$sKey]) !== null) {
118+
if (($unit = $aValues[$sKey]) !== null) {
119119
$parserState->consume($length);
120120
break;
121121
}
122122
}
123123
}
124-
return new Size((float) $size, $sUnit, $bIsColorComponent, $parserState->currentLine());
124+
return new Size((float) $size, $unit, $bIsColorComponent, $parserState->currentLine());
125125
}
126126

127127
/**
@@ -146,19 +146,19 @@ private static function getSizeUnits()
146146
}
147147

148148
/**
149-
* @param string $sUnit
149+
* @param string $unit
150150
*/
151-
public function setUnit($sUnit): void
151+
public function setUnit($unit): void
152152
{
153-
$this->sUnit = $sUnit;
153+
$this->unit = $unit;
154154
}
155155

156156
/**
157157
* @return string|null
158158
*/
159159
public function getUnit()
160160
{
161-
return $this->sUnit;
161+
return $this->unit;
162162
}
163163

164164
/**
@@ -193,18 +193,18 @@ public function isColorComponent()
193193
*/
194194
public function isSize(): bool
195195
{
196-
if (\in_array($this->sUnit, self::NON_SIZE_UNITS, true)) {
196+
if (\in_array($this->unit, self::NON_SIZE_UNITS, true)) {
197197
return false;
198198
}
199199
return !$this->isColorComponent();
200200
}
201201

202202
public function isRelative(): bool
203203
{
204-
if (\in_array($this->sUnit, self::RELATIVE_SIZE_UNITS, true)) {
204+
if (\in_array($this->unit, self::RELATIVE_SIZE_UNITS, true)) {
205205
return true;
206206
}
207-
if ($this->sUnit === null && $this->size != 0) {
207+
if ($this->unit === null && $this->size != 0) {
208208
return true;
209209
}
210210
return false;
@@ -225,6 +225,6 @@ public function render(OutputFormat $outputFormat): string
225225
$size = \preg_match('/[\\d\\.]+e[+-]?\\d+/i', (string) $this->size)
226226
? \preg_replace("/$sPoint?0+$/", '', \sprintf('%f', $this->size)) : (string) $this->size;
227227
return \preg_replace(["/$sPoint/", '/^(-?)0\\./'], ['.', '$1.'], $size)
228-
. ($this->sUnit ?? '');
228+
. ($this->unit ?? '');
229229
}
230230
}

0 commit comments

Comments
 (0)