Skip to content

Commit c6764aa

Browse files
authored
Merge pull request #85 from detook/scalar-getters
Scalar getters
2 parents 73e32bd + 3d92d82 commit c6764aa

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

source/AbstractPhysicalQuantity.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,20 @@ public static function getUnitDefinitions()
273273

274274
return static::$unitDefinitions;
275275
}
276+
277+
/**
278+
* @return float
279+
*/
280+
public function getOriginalValue()
281+
{
282+
return $this->originalValue;
283+
}
284+
285+
/**
286+
* @return string
287+
*/
288+
public function getOriginalUnit()
289+
{
290+
return $this->originalUnit;
291+
}
276292
}

source/PhysicalQuantityInterface.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,17 @@ public function subtract(PhysicalQuantityInterface $quantity);
7171
* @return boolean True if the quantities are the same, false if not.
7272
*/
7373
public function isEquivalentQuantity(PhysicalQuantityInterface $testQuantity);
74-
74+
75+
/**
76+
* @return float
77+
*/
78+
public function getOriginalValue();
79+
80+
/**
81+
* @return string
82+
*/
83+
public function getOriginalUnit();
84+
7585
/**
7686
* Verify if the given value respond to an already defined unit of meaure of the current
7787
* phisical quantity.
@@ -81,7 +91,7 @@ public function isEquivalentQuantity(PhysicalQuantityInterface $testQuantity);
8191
* @return boolean True if $name has been defined into the current physical quantity, false if not.
8292
*/
8393
public static function isUnitDefined($name);
84-
94+
8595
/**
8696
* Return a list of all the unit of measure defined in the current physical quantity
8797
*

tests/AbstractPhysicalQuantityTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,15 @@ public function testListAllUnits(): void
253253
$this->assertEquals($allUnits, $expected);
254254
}
255255

256+
public function testGetOriginalValue()
257+
{
258+
$value = 2;
259+
$unit = 'u';
260+
$physicalQuantity = new Wonkicity($value, $unit);
261+
$this->assertEquals($value, $physicalQuantity->getOriginalValue());
262+
$this->assertEquals($unit, $physicalQuantity->getOriginalUnit());
263+
}
264+
256265
/**
257266
* Attempting to register these units should throw a DuplicateUnitNameOrAlias.
258267
* 1) The name of the new unit to test

0 commit comments

Comments
 (0)