umirode / type
1.8
2020-02-17 10:02 UTC
Requires
- php: ^7.1
- beberlei/assert: ^3.2
- jawira/case-converter: ^3.4
Requires (Dev)
- phpunit/phpunit: ^7.0.1
README
Abstract type class for php application.
Installation
Using Composer:
composer require umirode/type
Example
Define type:
<?php declare(strict_types=1); use Umirode\Type\Type; /** * Class ExampleType * @package Umirode\Type * * @method bool isActive() * @method bool isAccepted() * @method bool isCanceledByCustomer() * @method static ExampleType active() * @method static ExampleType accepted() * @method static ExampleType canceledByCustomer() */ final class ExampleType extends Type { public const TYPES = [ 'active' => 'Active', 'accepted' => 'Accepted by admin', 'canceled_by_customer' => 'Canceled by customer' ]; }
Use it:
<?php $exampleType = new ExampleType('canceled_by_customer'); $exampleType = ExampleType::canceledByCustomer(); echo $exampleType->getValue(); // Canceled by customer