Page Menu
Home
GitPull.it
Search
Configure Global Search
Log In
Files
F12512209
D125.1775755452.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D125.1775755452.diff
View Options
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 {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 9, 19:24 (2 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1832826
Default Alt Text
D125.1775755452.diff (1 KB)
Attached To
Mode
D125: Update DataValueQuantity to work without a unit (for non-Wikidata Wikibases)
Attached
Detach File
Event Timeline
Log In to Comment