diff --git a/include/wb/Label.php b/include/wb/Label.php index 3e6dd6d..ebb4146 100644 --- a/include/wb/Label.php +++ b/include/wb/Label.php @@ -1,69 +1,112 @@ . # Wikibase namespace wb; /** - * An entity Label. + * A Wikibase Label * - * @see https://www.wikidata.org/wiki/Wikidata:Glossary#Label + * https://www.wikidata.org/wiki/Wikidata:Glossary#Label */ class Label { + /** + * @var string + */ public $language; + + /** + * @var string + */ public $value; + /** + * Constructor + * + * @var $language string Language code + * @var $value string Label value + */ public function __construct( $language, $value ) { $this->setLanguage( $language ) ->setValue( $value ); } + /** + * Get the language code + * + * @return string Language code + */ public function getLanguage() { return $this->language; } + /** + * Get the language value + * + * @return string + */ public function getValue() { return $this->value; } + /** + * Change the language + * + * This is more an internal method and should be avoided. + * + * @param $language string Language code + * @return self + */ public function setLanguage( $language ) { $this->language = $language; return $this; } + /** + * Set the label value + * + * @param $value Label value + * @return self + */ public function setValue( $value ) { $this->value = $value; return $this; } + /** + * Create a Label object from raw array data + * + * @param $data array + * @return self + */ public static function createFromData( $data ) { if( ! isset( $data['language'], $data['value'] ) ) { throw new WrongDataException( self::class ); } return new static( $data['language'], $data['value'] ); } /** * String rappresentation * * @return string */ public function __toString() { return sprintf( '%s: %s', $this->getLanguage(), $this->getValue() ); } }