Skip to content

Instantly share code, notes, and snippets.

@mikemilano
Created October 3, 2017 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikemilano/2145c6c8774175168ba79dfb6d50ad46 to your computer and use it in GitHub Desktop.
Save mikemilano/2145c6c8774175168ba79dfb6d50ad46 to your computer and use it in GitHub Desktop.
A simple PHP class which allows for chaining the setters.
<?php
class Motorcycle {
private $make;
private $model;
/**
* Returns the motorcycle make.
*
* @return string The motorcycle make
*/
public function getMake(): string
{
return $this-&gt;make;
}
/**
* Sets the make of the motorcycle.
*
* @param string $make The motorcycle make
*
* @return $this
*/
public function setMake(string $make): Motorcycle
{
$this-&gt;make = $make;
return $this;
}
/**
* Returns the motorcycle model.
*
* @return string The motorcycle model
*/
public function getModel(): string
{
return $this-&gt;model;
}
/**
* Sets the model of the motorcycle.
*
* @param string $model The motorcycle model
*
* @return $this
*/
public function setModel(string $model): Motorcycle
{
$this-&gt;model = $model;
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment