umirode/type

1.8 2020-02-17 10:02 UTC

This package is auto-updated.

Last update: 2024-04-19 07:03:23 UTC


README

PHP Version Stable Version Total Downloads Build Status

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