rickselby / consthelpers
1.2
2015-12-22 09:46 UTC
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2024-09-10 23:35:20 UTC
README
当使用具有许多常量的类时使用的辅助特质。
也是我测试CI内容的地方。
示例
class DataRef { use \ConstHelpers\Validating; const POINT_NORTH = 0; const POINT_SOUTH = 1; const POINT_EAST = 2; const POINT_WEST = 3; const POINT_UP = 4; const POINT_DOWN = 5; const ORIENT_NORMAL = 6; const ORIENT_INVERSE = 7; } // Get the list of constants that start with 'POINT_' $consts = DataRef::startsWith('POINT_')); // Validate a value against the constants starting with 'POINT_' if (DataRef::isValidStartsWith($value, 'POINT_')) { ... // Validate against constants matching a regular expression if (DataRef::isValid($value, '/T.*E/')) { ...