|
@@ -30,7 +30,7 @@ discard block |
|
|
block discarded – undo |
|
30
|
30
|
|
|
31
|
31
|
self::_init( ); |
|
32
|
32
|
|
|
33
|
|
- if( !static::_validate_constants( $scalar ) or !isset( self::$constants[ static::class ][ 1 ][ $scalar ] ) ) |
|
|
33
|
+ if ( !static::_validate_constants( $scalar ) or !isset( self::$constants[ static::class ][ 1 ][ $scalar ] ) ) |
|
34
|
34
|
throw new InvalidInitializerException; |
|
35
|
35
|
|
|
36
|
36
|
$this->scalar = $scalar; |
|
@@ -39,11 +39,11 @@ discard block |
|
|
block discarded – undo |
|
39
|
39
|
|
|
40
|
40
|
final public static function __callStatic( string $name, array $args ) { |
|
41
|
41
|
|
|
42
|
|
- if( !empty( $args ) ) throw new BadMethodCallException; |
|
|
42
|
+ if ( !empty( $args ) ) throw new BadMethodCallException; |
|
43
|
43
|
|
|
44
|
44
|
self::_init( ); |
|
45
|
45
|
|
|
46
|
|
- if( !isset( self::$constants[ static::class ][ 0 ][ $name ] ) ) |
|
|
46
|
+ if ( !isset( self::$constants[ static::class ][ 0 ][ $name ] ) ) |
|
47
|
47
|
throw new InvalidInitializerException; |
|
48
|
48
|
|
|
49
|
49
|
$class = static::class; |
|
@@ -59,12 +59,12 @@ discard block |
|
|
block discarded – undo |
|
59
|
59
|
|
|
60
|
60
|
private static function _init( ) { |
|
61
|
61
|
|
|
62
|
|
- if( isset( self::$constants[ static::class ] ) ) return; |
|
|
62
|
+ if ( isset( self::$constants[ static::class ] ) ) return; |
|
63
|
63
|
|
|
64
|
64
|
$csts = ( new ReflectionClass( static::class ) )->getConstants(); |
|
65
|
65
|
$vals = [ ]; |
|
66
|
66
|
|
|
67
|
|
- foreach( $csts as $key => $value ) { |
|
|
67
|
+ foreach ( $csts as $key => $value ) { |
|
68
|
68
|
|
|
69
|
69
|
assert( static::_validate_constants( $value ), new EnumConstantTypeException( static::class, $key, gettype( $value ) ) ); |
|
70
|
70
|
assert( !isset( $vals[ $value ] ), new DuplicatedConstantException( static::class, $key ) ); |
|
@@ -80,8 +80,8 @@ discard block |
|
|
block discarded – undo |
|
80
|
80
|
|
|
81
|
81
|
protected static function _validate_constants( $value ) : bool { |
|
82
|
82
|
|
|
83
|
|
- if( is_int( $value ) ) return true; |
|
84
|
|
- if( is_string( $value ) && $value !== '' ) return true; |
|
|
83
|
+ if ( is_int( $value ) ) return true; |
|
|
84
|
+ if ( is_string( $value ) && $value !== '' ) return true; |
|
85
|
85
|
return false; |
|
86
|
86
|
|
|
87
|
87
|
} |