Add more type hints and return types

Fixes #20
This commit is contained in:
Oliver Davies 2019-04-11 00:54:59 +01:00
parent 72ed0d6f24
commit a4c913ab38
4 changed files with 41 additions and 39 deletions

View file

@ -15,7 +15,7 @@ class Filter
/**
* @return static
*/
public static function create()
public static function create(): self
{
return new static();
}
@ -25,7 +25,7 @@ class Filter
*
* @return $this
*/
public function has($value)
public function has(string $value): self
{
$this->properties['hasTheWord'] = $value;
@ -37,7 +37,7 @@ class Filter
*
* @return $this
*/
public function hasNot($value)
public function hasNot(string $value): self
{
$this->properties['doesNotHaveTheWord'] = $value;
@ -49,7 +49,7 @@ class Filter
*
* @return $this
*/
public function from($values)
public function from($values): self
{
if (!empty($values)) {
$this->properties['from'] = collect($values)->map(function ($value) {
@ -65,7 +65,7 @@ class Filter
*
* @return $this
*/
public function to($values)
public function to($values): self
{
if (!empty($values)) {
$this->properties['to'] = collect($values)->map(function ($value) {
@ -81,7 +81,7 @@ class Filter
*
* @return $this
*/
public function subject($values)
public function subject($values): self
{
$this->properties['subject'] = collect($values)->map(function ($value) {
return json_encode($value);
@ -93,7 +93,7 @@ class Filter
/**
* @return $this
*/
public function hasAttachment()
public function hasAttachment(): self
{
$this->properties['hasAttachment'] = 'true';
@ -107,7 +107,7 @@ class Filter
*
* @return $this
*/
public function fromList($value)
public function fromList($value): self
{
$value = collect($value)->implode(self::SEPARATOR);
$this->has("list:{$value}");
@ -118,7 +118,7 @@ class Filter
/**
* @return $this
*/
public function excludeChats()
public function excludeChats(): self
{
$this->properties['excludeChats'] = 'true';
@ -130,7 +130,7 @@ class Filter
*
* @return $this
*/
public function label($label)
public function label(string $label): self
{
$this->properties['label'] = $label;
@ -140,7 +140,7 @@ class Filter
/**
* @return $this
*/
public function archive()
public function archive(): self
{
$this->properties['shouldArchive'] = 'true';
@ -152,7 +152,7 @@ class Filter
*
* @return $this
*/
public function labelAndArchive($label)
public function labelAndArchive(string $label): self
{
$this->label($label)->archive();
@ -162,7 +162,7 @@ class Filter
/**
* @return $this
*/
public function spam()
public function spam(): self
{
$this->properties['shouldSpam'] = 'true';
$this->properties['shouldNeverSpam'] = 'false';
@ -173,7 +173,7 @@ class Filter
/**
* @return $this
*/
public function neverSpam()
public function neverSpam(): self
{
$this->properties['shouldSpam'] = 'false';
$this->properties['shouldNeverSpam'] = 'true';
@ -184,7 +184,7 @@ class Filter
/**
* @return $this
*/
public function trash()
public function trash(): self
{
$this->properties['shouldTrash'] = 'true';
@ -194,7 +194,7 @@ class Filter
/**
* @return $this
*/
public function read()
public function read(): self
{
$this->properties['markAsRead'] = 'true';
@ -204,7 +204,7 @@ class Filter
/**
* @return $this
*/
public function star()
public function star(): self
{
$this->properties['shouldStar'] = 'true';
@ -216,7 +216,7 @@ class Filter
*
* @return $this
*/
public function forward($to)
public function forward(string $to): self
{
$this->properties['forwardTo'] = $to;
@ -226,7 +226,7 @@ class Filter
/**
* @return $this
*/
public function important()
public function important(): self
{
$this->properties['shouldAlwaysMarkAsImportant'] = 'true';
@ -236,7 +236,7 @@ class Filter
/**
* @return $this
*/
public function notImportant()
public function notImportant(): self
{
$this->properties['shouldNeverMarkAsImportant'] = 'true';
@ -248,7 +248,7 @@ class Filter
*
* @return $this
*/
public function categorise($category)
public function categorise(string $category): self
{
$this->properties['smartLabelToApply'] = $category;
@ -261,7 +261,7 @@ class Filter
* @return array
* @deprecated toArray()
*/
public function getProperties()
public function getProperties(): array
{
return $this->properties;
}
@ -271,7 +271,7 @@ class Filter
*
* @return array
*/
public function toArray()
public function toArray(): array
{
return $this->properties;
}