More consistent fluency in Item API

This commit is contained in:
Dylan K. Taylor
2019-03-23 12:20:35 +00:00
parent 1045088668
commit d4fe004375
5 changed files with 41 additions and 20 deletions

View File

@ -56,14 +56,17 @@ class WrittenBook extends WritableBook{
* Sets the generation of a book.
*
* @param int $generation
*
* @return $this
*/
public function setGeneration(int $generation) : void{
public function setGeneration(int $generation) : self{
if($generation < 0 or $generation > 3){
throw new \InvalidArgumentException("Generation \"$generation\" is out of range");
}
$namedTag = $this->getNamedTag();
$namedTag->setInt(self::TAG_GENERATION, $generation);
$this->setNamedTag($namedTag);
return $this;
}
/**
@ -81,11 +84,14 @@ class WrittenBook extends WritableBook{
* Sets the author of this book.
*
* @param string $authorName
*
* @return $this
*/
public function setAuthor(string $authorName) : void{
public function setAuthor(string $authorName) : self{
$namedTag = $this->getNamedTag();
$namedTag->setString(self::TAG_AUTHOR, $authorName);
$this->setNamedTag($namedTag);
return $this;
}
/**
@ -101,10 +107,13 @@ class WrittenBook extends WritableBook{
* Sets the author of this book.
*
* @param string $title
*
* @return $this
*/
public function setTitle(string $title) : void{
public function setTitle(string $title) : self{
$namedTag = $this->getNamedTag();
$namedTag->setString(self::TAG_TITLE, $title);
$this->setNamedTag($namedTag);
return $this;
}
}