Skip to content

Instantly share code, notes, and snippets.

@crisu83
Created April 19, 2015 07:09
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 crisu83/3bd751e99ae80e9f336c to your computer and use it in GitHub Desktop.
Save crisu83/3bd751e99ae80e9f336c to your computer and use it in GitHub Desktop.
Immutable status class.
<?php
class Status
{
const PUBLISHED = 10;
const DRAFT = 20;
private $status;
public static function published()
{
return new self(self::PUBLISHED);
}
public static function draft()
{
return new self(self::DRAFT);
}
private function __construct($anStatus)
{
$this->status = $anStatus;
}
public function equalsTo(self $anStatus)
{
return $this->status === $anStatus->status;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment