doctrineum/strict-string

此包已被弃用且不再维护。作者建议使用 doctrineum/scalar 包代替。

Doctrine 枚举类型 - 仅字符串

2.1.1 2015-08-04 15:18 UTC

This package is auto-updated.

Last update: 2019-02-20 19:57:02 UTC


README

Build Status

关于

Doctrine 枚举,仅允许字符串。

示例


$stringEnum = StrictStringEnum::getEnum('foo bar');

$stringEnum = StrictStringEnum::getEnum('12345');

// throws an exception - only string is allowed
$stringEnum = StrictStringEnum::getEnum('');

// throws an exception - only string is allowed
StrictStringEnum::getEnum(12);

// throws an exception - only string is allowed
StrictStringEnum::getEnum(false);

// throws an exception - only string is allowed
StrictStringEnum::getEnum(null);

// throws an exception - only string is allowed
StrictStringEnum::getEnum(new ObjectWithToStringMethod('foo'));

Doctrine 集成

有关新 Doctrine 类型注册的详细信息,请参阅父项目 Doctrineum