Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Status {
- public const CODES = [
- ......
- ];
- protected $code;
- public function __construct(string $code) {
- if (!$this->codeIsKnown($code)){
- throw new Exception\UnknownStatusCodeException('Unknown code: '.$code);
- }
- $this->code = $code;
- }
- protected function codeIsKnown(string $code):bool{
- return in_array($code, self::CODES);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement