umirode/type

1.8 2020-02-17 10:02 UTC

This package is auto-updated.

Last update: 2024-09-19 08:04:50 UTC


README

PHP Version Stable Version Total Downloads Build Status

为PHP应用提供抽象类型类。

安装

使用Composer

composer require umirode/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'
    ];
}

使用它

<?php

$exampleType = new ExampleType('canceled_by_customer');
$exampleType = ExampleType::canceledByCustomer();

echo $exampleType->getValue(); // Canceled by customer