Skip to content

Commit 04f281a

Browse files
committed
Rename measure to num
1 parent bc64364 commit 04f281a

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/Compound/AbstractCompoundMeasurement.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
abstract class AbstractCompoundMeasurement extends AbstractMeasurement
1212
{
13-
abstract public AbstractMeasurement $measure {
13+
abstract public AbstractMeasurement $num {
1414
get;
1515
}
1616
abstract public AbstractMeasurement $deno {
@@ -27,10 +27,10 @@ abstract class AbstractCompoundMeasurement extends AbstractMeasurement
2727

2828
public string $unit {
2929
set {
30-
[$measureUnit, $denoUnit] = $this->normalizeAndSplitUnit($value);
30+
[$numUnit, $denoUnit] = $this->normalizeAndSplitUnit($value);
3131

3232
$this->unit = $this->normalizeCompoundUnit($value);
33-
$this->measure = $this->measure->withUnit($measureUnit);
33+
$this->num = $this->num->withUnit($numUnit);
3434

3535
if ($denoUnit) {
3636
$this->deno = $this->deno->withUnit($denoUnit);
@@ -57,7 +57,7 @@ public function withParse(
5757
$values = static::parseValue($value);
5858

5959
$atomValue = BigDecimal::zero();
60-
$atomUnit = $this->measure->atomUnit . '/' . $this->deno->atomUnit;
60+
$atomUnit = $this->num->atomUnit . '/' . $this->deno->atomUnit;
6161
$new = $this->with(0, $atomUnit);
6262

6363
foreach ($values as [$val, $unit]) {
@@ -143,32 +143,32 @@ public function convertTo(
143143
}
144144

145145
// Compound exchange, for example, m/s to km/h.
146-
// Must split the unit into measure and denominator to exchange them.
147-
[$measureUnit, $denoUnit] = $new->normalizeAndSplitUnit($toUnit);
146+
// Must split the unit into numerator and denominator to exchange them.
147+
[$numUnit, $denoUnit] = $new->normalizeAndSplitUnit($toUnit);
148148

149149
return $new->convertUnitPairTo(
150-
$measureUnit,
150+
$numUnit,
151151
$denoUnit,
152152
$scale,
153153
$roundingMode
154154
);
155155
}
156156

157157
public function convertUnitPairTo(
158-
string $measureUnit,
158+
string $numUnit,
159159
string $denoUnit = '',
160160
?int $scale = null,
161161
RoundingMode $roundingMode = RoundingMode::DOWN
162162
): static {
163163
$new = $this;
164164

165-
// If we have a measure unit, we need to convert the value accordingly.
166-
if ($measureUnit) {
167-
$this->measure = $this->measure->with($this->value)
168-
->convertTo($measureUnit, $scale, $roundingMode);
165+
// If we have a num unit, we need to convert the value accordingly.
166+
if ($numUnit) {
167+
$this->num = $this->num->with($this->value)
168+
->convertTo($numUnit, $scale, $roundingMode);
169169

170-
$new = $this->withValue($this->measure->value);
171-
$new->unit = $measureUnit;
170+
$new = $this->withValue($this->num->value);
171+
$new->unit = $numUnit;
172172
}
173173

174174
// If we have a denominator unit, we need to convert the value accordingly.
@@ -202,7 +202,7 @@ public function normalizeAndSplitUnit(string $unit): array
202202

203203
$units = explode('/', $unit, 2) + ['', ''];
204204

205-
$units[0] = $this->measure->normalizeUnit($units[0]);
205+
$units[0] = $this->num->normalizeUnit($units[0]);
206206
$units[1] = $this->deno->normalizeUnit($units[1]);
207207

208208
return $units;
@@ -230,14 +230,14 @@ public function format(
230230
if (!$suffix) {
231231
$suffix = $unit ?? $this->unit;
232232

233-
if ($this->measure->getUnitExchangeRate($suffix) !== null) {
233+
if ($this->num->getUnitExchangeRate($suffix) !== null) {
234234
$suffix .= '/' . $this->deno->formatSuffix($this->deno->unit, $this->value, $this->deno->unit);
235235
}
236236
}
237237

238238
$text = parent::format($suffix, $unit, $scale, $roundingMode);
239239

240-
if ($addDenoSuffix && $this->measure->getUnitExchangeRate($suffix) !== null) {
240+
if ($addDenoSuffix && $this->num->getUnitExchangeRate($suffix) !== null) {
241241
$text .= '/' . $this->deno->formatSuffix($this->deno->unit, $this->value, $this->deno->unit);
242242
}
243243

src/Compound/Bitrate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class Bitrate extends AbstractCompoundMeasurement
3030

3131
public const string UNIT_TIBPS = 'Tibps';
3232

33-
public AbstractMeasurement $measure {
34-
get => $this->measure ??= new FileSize();
33+
public AbstractMeasurement $num {
34+
get => $this->num ??= new FileSize();
3535
}
3636

3737
public AbstractMeasurement $deno {

src/Compound/Speed.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class Speed extends AbstractCompoundMeasurement
1919

2020
public string $defaultUnit = 'm/s';
2121

22-
public AbstractMeasurement $measure {
23-
get => $this->measure ??= new Length();
22+
public AbstractMeasurement $num {
23+
get => $this->num ??= new Length();
2424
}
2525

2626
protected array $compoundUnitExchanges = [

0 commit comments

Comments
 (0)