-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better documentation for the DataValue::newFromArray contract
- Loading branch information
1 parent
6498e61
commit 9a7a567
Showing
2 changed files
with
25 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ class DecimalValue extends DataValueObject { | |
* @param string|int|float $value If given as a string, the value must match | ||
* QUANTITY_VALUE_PATTERN. The leading plus sign is optional. | ||
* | ||
* @throws IllegalValueException | ||
* @throws InvalidArgumentException | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
thiemowmde
Author
Contributor
|
||
*/ | ||
public function __construct( $value ) { | ||
if ( is_int( $value ) || is_float( $value ) ) { | ||
|
@@ -112,8 +112,6 @@ private function convertToDecimal( $number ) { | |
/** | ||
* Compares this DecimalValue to another DecimalValue. | ||
* | ||
* @since 0.1 | ||
* | ||
* @param self $that | ||
* | ||
* @throws LogicException | ||
|
@@ -227,8 +225,6 @@ public function getValue() { | |
/** | ||
* Returns the sign of the amount (+ or -). | ||
* | ||
* @since 0.1 | ||
* | ||
* @return string "+" or "-". | ||
*/ | ||
public function getSign() { | ||
|
@@ -288,8 +284,6 @@ public function computeAbsolute() { | |
* Returns the integer part of the value, that is, the part before the decimal point, | ||
* without the sign. | ||
* | ||
* @since 0.1 | ||
* | ||
* @return string | ||
*/ | ||
public function getIntegerPart() { | ||
|
@@ -306,8 +300,6 @@ public function getIntegerPart() { | |
* Returns the fractional part of the value, that is, the part after the decimal point, | ||
* if any. | ||
* | ||
* @since 0.1 | ||
* | ||
* @return string | ||
*/ | ||
public function getFractionalPart() { | ||
|
@@ -342,8 +334,6 @@ public function getTrimmed() { | |
* Returns the value held by this object, as a float. | ||
* Equivalent to floatval( $this->getvalue() ). | ||
* | ||
* @since 0.1 | ||
* | ||
* @return float | ||
*/ | ||
public function getValueFloat() { | ||
|
@@ -360,13 +350,20 @@ public function getArrayValue() { | |
} | ||
|
||
/** | ||
* Constructs a new instance of the DataValue from the provided data. | ||
* This can round-trip with @see getArrayValue | ||
* Constructs a new instance from the provided data. Required for @see DataValueDeserializer. | ||
* This is expected to round-trip with @see getArrayValue. | ||
* | ||
* @deprecated since 0.8.3. Static DataValue::newFromArray constructors like this are | ||
* underspecified (not in the DataValue interface), and misleadingly named (should be named | ||
* newFromArrayValue). Instead, use DataValue builder callbacks in @see DataValueDeserializer. | ||
* | ||
* @param string|int|float $data | ||
* @param mixed $data Warning! Even if this is expected to be a value as returned by | ||
* @see getArrayValue, callers of this specific newFromArray implementation can not guarantee | ||
* this. This is not guaranteed to be a string! | ||
* | ||
* @throws InvalidArgumentException if $data is not in the expected format. Subclasses of | ||
* InvalidArgumentException are expected and properly handled by @see DataValueDeserializer. | ||
* @return self | ||
* @throws IllegalValueException | ||
*/ | ||
public static function newFromArray( $data ) { | ||
return new static( $data ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IllegalValueException is InvalidArgumentException, why change this?