diff --git "a/include/class-wb\\DataValue.php" "b/include/class-wb\\DataValue.php" index 4465a40..8d03f08 100644 --- "a/include/class-wb\\DataValue.php" +++ "b/include/class-wb\\DataValue.php" @@ -1,69 +1,98 @@ . # Wikibase namespace wb; /** * A generic DataValue is part of a Snak. */ class DataValue { var $type; var $value; /** + * Constructor + * * @param $type string Type * @param $value mixed Value */ public function __construct( $type, $value ) { $this->setType( $type ) ->setValue( $value ); } + /** + * Get the type + * + * @return string + */ public function getType() { return $this->type; } + /** + * Get the value + * + * @return mixed + */ public function getValue() { return $this->value; } + /** + * Set the type + */ public function setType( $type ) { $this->type = $type; return $this; } + /** + * Set the value + * + * @param mixed $value + * @return self + */ public function setValue( $value ) { $this->value = $value; return $this; } + /** + * Static constructor from a standard object + * + * @param object $data + * @return self + */ public static function createFromData( $data ) { if( ! isset( $data['type'], $data['value'] ) ) { throw new WrongDataException( __CLASS__ ); } return new self( $data['type'], $data['value'] ); } /** + * Get this object in form of a string + * * @return string */ public function __toString() { - return $this->getValue(); + return json_encode( $this->getValue() ); } }