diff --git a/include/wb/DataValueQuantity.php b/include/wb/DataValueQuantity.php --- a/include/wb/DataValueQuantity.php +++ b/include/wb/DataValueQuantity.php @@ -30,10 +30,17 @@ * @param $lower_bound mixed The $value at its minimum error e.g. -1 */ public function __construct( $amount, $wikidata_unit_id, $upper_bound = null, $lower_bound = null ) { - $value = [ - 'amount' => self::sign( $amount ), - 'unit' => "http://www.wikidata.org/entity/$wikidata_unit_id" - ]; + if (($wikidata_unit_id == null) or (strtoupper(substr($wikidata_unit_id, 0)) == "Q")) { + $value = [ + 'amount' => self::sign($amount), + 'unit' => "1" + ]; + } else { + $value = [ + 'amount' => self::sign($amount), + 'unit' => "http://www.wikidata.org/entity/$wikidata_unit_id" + ]; + } if( null !== $upper_bound ) { $value['upperBound'] = self::int2string( $upper_bound ); } diff --git a/include/wb/SnakQuantity.php b/include/wb/SnakQuantity.php --- a/include/wb/SnakQuantity.php +++ b/include/wb/SnakQuantity.php @@ -24,8 +24,11 @@ class SnakQuantity extends Snak { /** - * @param $property string Wikidata property as 'P123' - * @param $value string + * @param $property string Property as 'P123' + * @param $value mixed amount Any number e.g. 0 + * @param $wikidata_unit_id string Wikidata ID of a unit e.g. 'Q11573' for metre + * @param $upper_bound mixed The $value at its maximum error e.g. +1 + * @param $lower_bound mixed The $value at its minimum error e.g. -1 */ public function __construct( $property, $amount, $unit, $upper_bound = null, $lower_bound = null ) { return parent::__construct( diff --git a/include/wb/StatementQuantity.php b/include/wb/StatementQuantity.php --- a/include/wb/StatementQuantity.php +++ b/include/wb/StatementQuantity.php @@ -19,7 +19,7 @@ namespace wb; /** - * A StatementString is a Statement that contains a SnakString. + * A StatementQuantity is a Statement that contains a SnakQuantity. */ class StatementQuantity extends Statement {