Passed
Push — master ( f34f5c...ba26d1 )
by 4kizuki
02:19
created
src/Enum.php 1 patch
Braces   +21 added lines, -11 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( !self::_validate_constants( $scalar ) or !isset( self::$___constants[ static::class ][ 1 ][ $scalar ] ) )
34
-            throw new InvalidInitializerException;
33
+        if( !self::_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 ] );
@@ -60,11 +64,13 @@  discard block
 block discarded – undo
60 64
 
61 65
             foreach( $csts as $key => $value ) {
62 66
 
63
-                if( !static::_validate_constants( $value ) )
64
-                    throw new EnumConstantTypeException( static::class, $key, gettype( $value ) );
67
+                if( !static::_validate_constants( $value ) ) {
68
+                                    throw new EnumConstantTypeException( static::class, $key, gettype( $value ) );
69
+                }
65 70
 
66
-                if( isset( $vals[ $value ] ) )
67
-                    throw new DuplicatedConstantException( static::class, $key );
71
+                if( isset( $vals[ $value ] ) ) {
72
+                                    throw new DuplicatedConstantException( static::class, $key );
73
+                }
68 74
                 
69 75
                 $vals[$value] = true;
70 76
 
@@ -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.