Created
April 19, 2015 07:09
-
-
Save crisu83/3bd751e99ae80e9f336c to your computer and use it in GitHub Desktop.
Immutable status class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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