Passed
Push — master ( 0e8760...e8c123 )
by 4kizuki
01:58
created
src/Enum.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -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
     }
Please login to merge, or discard this patch.
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -30,8 +30,9 @@  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 ] ) )
34
-            throw new InvalidInitializerException;
33
+        if( !static::_validate_constants( $scalar ) or !isset( self::$constants[ static::class ][ 1 ][ $scalar ] ) ) {
34
+                    throw new InvalidInitializerException;
35
+        }
35 36
 
36 37
         $this->scalar = $scalar;
37 38
 
@@ -39,12 +40,15 @@  discard block
 block discarded – undo
39 40
 
40 41
     final public static function __callStatic( string $name, array $args ) {
41 42
 
42
-        if( !empty( $args ) ) throw new BadMethodCallException;
43
+        if( !empty( $args ) ) {
44
+            throw new BadMethodCallException;
45
+        }
43 46
 
44 47
         self::_init( );
45 48
 
46
-        if( !isset( self::$constants[ static::class ][ 0 ][ $name ] ) )
47
-            throw new InvalidInitializerException;
49
+        if( !isset( self::$constants[ static::class ][ 0 ][ $name ] ) ) {
50
+                    throw new InvalidInitializerException;
51
+        }
48 52
 
49 53
         $class = static::class;
50 54
         return new $class( self::$constants[ static::class ][ 0 ][ $name ] );
@@ -59,7 +63,9 @@  discard block
 block discarded – undo
59 63
 
60 64
     private static function _init( ) {
61 65
 
62
-        if( isset( self::$constants[ static::class ] ) ) return;
66
+        if( isset( self::$constants[ static::class ] ) ) {
67
+            return;
68
+        }
63 69
 
64 70
         $csts = ( new ReflectionClass( static::class ) )->getConstants();
65 71
         $vals = [ ];
@@ -80,8 +86,12 @@  discard block
 block discarded – undo
80 86
 
81 87
     protected static function _validate_constants( $value ) : bool {
82 88
 
83
-        if( is_int( $value ) ) return true;
84
-        if( is_string( $value ) && $value !== '' ) return true;
89
+        if( is_int( $value ) ) {
90
+            return true;
91
+        }
92
+        if( is_string( $value ) && $value !== '' ) {
93
+            return true;
94
+        }
85 95
         return false;
86 96
 
87 97
     }
Please login to merge, or discard this patch.