Skip to content

Commit

Permalink
Explicit return types for all methods
Browse files Browse the repository at this point in the history
  • Loading branch information
robinvdvleuten committed May 27, 2019
1 parent b0c94ea commit 9d25db8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/PersonName.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function last(): ?string
*
* @return string
*/
public function full()
public function full(): string
{
return $this->last ? "{$this->first} {$this->last}" : $this->first;
}
Expand All @@ -69,7 +69,7 @@ public function full()
*
* @return string
*/
public function familiar()
public function familiar(): string
{
return $this->last ? "{$this->first} {$this->last[0]}." : $this->first;
}
Expand All @@ -79,7 +79,7 @@ public function familiar()
*
* @return string
*/
public function abbreviated()
public function abbreviated(): string
{
return $this->last ? "{$this->first[0]}. {$this->last}" : $this->first;
}
Expand All @@ -89,7 +89,7 @@ public function abbreviated()
*
* @return string
*/
public function sorted()
public function sorted(): string
{
return $this->last ? "{$this->last}, {$this->first}" : $this->first;
}
Expand All @@ -99,7 +99,7 @@ public function sorted()
*
* @return string
*/
public function possessive()
public function possessive(): string
{
return sprintf('%s\'%s', $this, substr($this, -1) !== 's' ? 's' : '');
}
Expand All @@ -109,7 +109,7 @@ public function possessive()
*
* @return string
*/
public function initials()
public function initials(): string
{
preg_match_all('/([[:word:]])[[:word:]]+/i', preg_replace('/(\(|\[).*(\)|\])/', '', $this), $matches);

Expand All @@ -121,7 +121,7 @@ public function initials()
*
* @return string
*/
public function mentionable()
public function mentionable(): string
{
return strtolower(preg_replace('/\s+/', '', substr($this->familiar, 0, -1)));
}
Expand All @@ -130,14 +130,14 @@ public function mentionable()
* Make the methods accessibles as attributes.
*
* @param string $attribute
* @return string
* @return mixed
*/
public function __get($attribute)
{
return call_user_func([$this, $attribute]);
}

public function __toString()
public function __toString(): string
{
return $this->full;
}
Expand Down

0 comments on commit 9d25db8

Please sign in to comment.