Passed
Branch master (34b941)
by 4kizuki
08:47
created
src/StringEnum.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
  */
17 17
 abstract class StringEnum extends Enum {
18 18
 
19
-    public function __construct( string $scalar ) {
19
+    public function __construct(string $scalar) {
20 20
 
21
-        parent::__construct( $scalar );
21
+        parent::__construct($scalar);
22 22
 
23 23
     }
24 24
 
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 
29 29
     }
30 30
 
31
-    final protected static function _validate_constants( $value ) : bool {
31
+    final protected static function _validate_constants($value) : bool {
32 32
 
33
-        return ( is_string( $value ) && $value !== '' );
33
+        return (is_string($value) && $value !== '');
34 34
 
35 35
     }
36 36
     
Please login to merge, or discard this patch.
src/IntEnum.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
  */
17 17
 abstract class IntEnum extends Enum {
18 18
 
19
-    public function __construct( int $scalar ) {
19
+    public function __construct(int $scalar) {
20 20
 
21
-        parent::__construct( $scalar );
21
+        parent::__construct($scalar);
22 22
 
23 23
     }
24 24
 
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 
29 29
     }
30 30
 
31
-    final protected static function _validate_constants( $value ) : bool {
31
+    final protected static function _validate_constants($value) : bool {
32 32
 
33
-        return is_int( $value );
33
+        return is_int($value);
34 34
 
35 35
     }
36 36
     
Please login to merge, or discard this patch.
src/Exceptions/EnumConstantTypeException.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@
 block discarded – undo
17 17
  */
18 18
 class EnumConstantTypeException extends LogicException {
19 19
     
20
-    public function __construct( string $className, string $constName, string $constType ) {
21
-        parent::__construct( "Disallowed constant \"{$className}::{$constName}\": \"{$constType}\"." );
20
+    public function __construct(string $className, string $constName, string $constType) {
21
+        parent::__construct("Disallowed constant \"{$className}::{$constName}\": \"{$constType}\".");
22 22
     }
23 23
     
24 24
 }
Please login to merge, or discard this patch.
src/Exceptions/InvalidInitializer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 class InvalidInitializer extends InvalidArgumentException {
18 18
     
19 19
     public function __construct( ) {
20
-        parent::__construct( "Invalid enum initializer given. Given initializer isn't found in enum constants." );
20
+        parent::__construct("Invalid enum initializer given. Given initializer isn't found in enum constants.");
21 21
     }
22 22
     
23 23
 }
Please login to merge, or discard this patch.
src/Enum.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -25,44 +25,44 @@  discard block
 block discarded – undo
25 25
     private static $___constants = [ ];
26 26
     protected $scalar;
27 27
 
28
-    public function __construct( $scalar ) {
28
+    public function __construct($scalar) {
29 29
 
30 30
         self::_init( );
31 31
 
32
-        if( !self::_validate_constants( $scalar ) or !isset( self::$___constants[ static::class ][ 1 ][ $scalar ] ) )
32
+        if (!self::_validate_constants($scalar) or !isset(self::$___constants[ static::class ][ 1 ][ $scalar ]))
33 33
             throw new InvalidInitializer;
34 34
 
35 35
         $this->scalar = $scalar;
36 36
 
37 37
     }
38 38
 
39
-    final public static function __callStatic( string $name, array $args ) {
39
+    final public static function __callStatic(string $name, array $args) {
40 40
 
41
-        if( !empty( $args ) ) throw new InvalidArgumentException( );
41
+        if (!empty($args)) throw new InvalidArgumentException( );
42 42
 
43 43
         self::_init( );
44 44
 
45
-        if( !isset( self::$___constants[ static::class ][ 0 ][ $name ] ) )
45
+        if (!isset(self::$___constants[ static::class ][ 0 ][ $name ]))
46 46
             throw new InvalidInitializer( );
47 47
 
48 48
         $class = static::class;
49
-        return new $class( self::$___constants[ static::class ][ 0 ][ $name ] );
49
+        return new $class(self::$___constants[ static::class ][ 0 ][ $name ]);
50 50
 
51 51
     }
52 52
 
53 53
     final protected static function _init( ) {
54 54
 
55
-        if( !isset( self::$___constants[ static::class ] ) ) {
55
+        if (!isset(self::$___constants[ static::class ])) {
56 56
 
57
-            $csts = ( new ReflectionClass( static::class ) )->getConstants( );
57
+            $csts = (new ReflectionClass(static::class))->getConstants( );
58 58
             $vals = [ ];
59 59
 
60
-            foreach( $csts as $key => $value ) {
60
+            foreach ($csts as $key => $value) {
61 61
 
62
-                if( !static::_validate_constants( $value ) )
63
-                    throw new EnumConstantTypeException( static::class, $key, gettype( $value ) );
62
+                if (!static::_validate_constants($value))
63
+                    throw new EnumConstantTypeException(static::class, $key, gettype($value));
64 64
 
65
-                $vals[$value] = true;
65
+                $vals[ $value ] = true;
66 66
 
67 67
             }
68 68
 
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 
75 75
     public function value( ) { return $this->scalar; }
76 76
 
77
-    protected static function _validate_constants( $value ) : bool {
77
+    protected static function _validate_constants($value) : bool {
78 78
 
79
-        if( is_int( $value ) ) return true;
80
-        if( is_string( $value ) && $value !== '' ) return true;
79
+        if (is_int($value)) return true;
80
+        if (is_string($value) && $value !== '') return true;
81 81
         return false;
82 82
 
83 83
     }
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,8 +29,9 @@  discard block
 block discarded – undo
29 29
 
30 30
         self::_init( );
31 31
 
32
-        if( !self::_validate_constants( $scalar ) or !isset( self::$___constants[ static::class ][ 1 ][ $scalar ] ) )
33
-            throw new InvalidInitializer;
32
+        if( !self::_validate_constants( $scalar ) or !isset( self::$___constants[ static::class ][ 1 ][ $scalar ] ) ) {
33
+                    throw new InvalidInitializer;
34
+        }
34 35
 
35 36
         $this->scalar = $scalar;
36 37
 
@@ -38,12 +39,15 @@  discard block
 block discarded – undo
38 39
 
39 40
     final public static function __callStatic( string $name, array $args ) {
40 41
 
41
-        if( !empty( $args ) ) throw new InvalidArgumentException( );
42
+        if( !empty( $args ) ) {
43
+            throw new InvalidArgumentException( );
44
+        }
42 45
 
43 46
         self::_init( );
44 47
 
45
-        if( !isset( self::$___constants[ static::class ][ 0 ][ $name ] ) )
46
-            throw new InvalidInitializer( );
48
+        if( !isset( self::$___constants[ static::class ][ 0 ][ $name ] ) ) {
49
+                    throw new InvalidInitializer( );
50
+        }
47 51
 
48 52
         $class = static::class;
49 53
         return new $class( self::$___constants[ static::class ][ 0 ][ $name ] );
@@ -59,8 +63,9 @@  discard block
 block discarded – undo
59 63
 
60 64
             foreach( $csts as $key => $value ) {
61 65
 
62
-                if( !static::_validate_constants( $value ) )
63
-                    throw new EnumConstantTypeException( static::class, $key, gettype( $value ) );
66
+                if( !static::_validate_constants( $value ) ) {
67
+                                    throw new EnumConstantTypeException( static::class, $key, gettype( $value ) );
68
+                }
64 69
 
65 70
                 $vals[$value] = true;
66 71
 
@@ -76,8 +81,12 @@  discard block
 block discarded – undo
76 81
 
77 82
     protected static function _validate_constants( $value ) : bool {
78 83
 
79
-        if( is_int( $value ) ) return true;
80
-        if( is_string( $value ) && $value !== '' ) return true;
84
+        if( is_int( $value ) ) {
85
+            return true;
86
+        }
87
+        if( is_string( $value ) && $value !== '' ) {
88
+            return true;
89
+        }
81 90
         return false;
82 91
 
83 92
     }
Please login to merge, or discard this patch.