Created
June 10, 2019 18:14
-
-
Save tuscanicz/3013d6dc27d3f47c4a9392a0eaeeef20 to your computer and use it in GitHub Desktop.
Enum usage example
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 | |
declare(strict_types = 1); | |
class ClientAppStatusEnum extends \Tuscanicz\Enum | |
{ | |
public const STATUS_LOCKED = 0; | |
public const STATUS_ACTIVE = 1; | |
public const STATUS_TEMPORARY_DISABLED = 2; | |
} | |
class User | |
{ | |
/** | |
* @Enum(class=ClientAppStatusEnum::class) | |
* @ORM\Column(type="string_enum") | |
* @var ClientAppStatusEnum | |
*/ | |
private $status; | |
public function setStatus(ClientAppStatusEnum $status): void | |
{ | |
$this->status = $status; | |
} | |
} | |
$user = new \App\Entity\User(...); | |
$user->setStatus(ClientAppStatusEnum::get(ClientAppStatusEnum::STATUS_ACTIVE)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment