| @@ -32,21 +32,21 @@ discard block | ||
| 32 | 32 | */ | 
| 33 | 33 | public static function addClassMethod(string $class_name, string $name, Closure $fun): void | 
| 34 | 34 |      { | 
| 35 | -        if(self::isPrototypeable($class_name)){ | |
| 36 | -            if(!method_exists($class_name, $name)){ | |
| 35 | +        if (self::isPrototypeable($class_name)) { | |
| 36 | +            if (!method_exists($class_name, $name)) { | |
| 37 | 37 | self::$methods[$class_name] ??= []; | 
| 38 | -                if(!self::classHasPrototypeMethod($class_name, $name)){ | |
| 38 | +                if (!self::classHasPrototypeMethod($class_name, $name)) { | |
| 39 | 39 | self::$methods[$class_name][$name] = $fun; | 
| 40 | 40 | } | 
| 41 | -                else{ | |
| 41 | +                else { | |
| 42 | 42 |                      throw new Exception("Invalid method name provided for class '$class_name': method '$name' is already a Prototype"); | 
| 43 | 43 | } | 
| 44 | 44 | } | 
| 45 | -            else{ | |
| 45 | +            else { | |
| 46 | 46 |                  throw new Exception("Invalid method name provided for class '$class_name': method '$name' already exists"); | 
| 47 | 47 | } | 
| 48 | 48 | } | 
| 49 | -        else{ | |
| 49 | +        else { | |
| 50 | 50 |              throw new Exception("Invalid class provided: class '$class_name' is not Prototypeable"); | 
| 51 | 51 | } | 
| 52 | 52 | } | 
| @@ -59,21 +59,21 @@ discard block | ||
| 59 | 59 | */ | 
| 60 | 60 | public static function addClassStaticMethod(string $class_name, string $name, Closure $fun): void | 
| 61 | 61 |      { | 
| 62 | -        if(self::isPrototypeable($class_name)){ | |
| 63 | -            if(!method_exists($class_name, $name)){ | |
| 62 | +        if (self::isPrototypeable($class_name)) { | |
| 63 | +            if (!method_exists($class_name, $name)) { | |
| 64 | 64 | self::$static_methods[$class_name] ??= []; | 
| 65 | -                if(!self::classHasPrototypeMethod($class_name, $name)){ | |
| 65 | +                if (!self::classHasPrototypeMethod($class_name, $name)) { | |
| 66 | 66 | self::$static_methods[$class_name][$name] = $fun; | 
| 67 | 67 | } | 
| 68 | -                else{ | |
| 68 | +                else { | |
| 69 | 69 |                      throw new Exception("Invalid method name provided for class '$class_name': method '$name' is already a Prototype"); | 
| 70 | 70 | } | 
| 71 | 71 | } | 
| 72 | -            else{ | |
| 72 | +            else { | |
| 73 | 73 |                  throw new Exception("Invalid method name provided for class '$class_name': method '$name' already exists"); | 
| 74 | 74 | } | 
| 75 | 75 | } | 
| 76 | -        else{ | |
| 76 | +        else { | |
| 77 | 77 |              throw new Exception("Invalid class provided: class '$class_name' is not Prototypeable"); | 
| 78 | 78 | } | 
| 79 | 79 | } | 
| @@ -88,11 +88,11 @@ discard block | ||
| 88 | 88 |      { | 
| 89 | 89 | $class_name = get_class($obj); | 
| 90 | 90 | self::$methods[$class_name] ??= []; | 
| 91 | -        if(isset(self::$methods[$class_name][$name])){ | |
| 91 | +        if (isset(self::$methods[$class_name][$name])) { | |
| 92 | 92 | $closure = self::$methods[$class_name][$name]; | 
| 93 | 93 | return $closure->call($obj, ...$args); | 
| 94 | 94 | } | 
| 95 | -        else{ | |
| 95 | +        else { | |
| 96 | 96 |              throw new Error("Call to undefined method $class_name::$name()"); | 
| 97 | 97 | } | 
| 98 | 98 | } | 
| @@ -106,11 +106,11 @@ discard block | ||
| 106 | 106 | public static function callStatic(string $class_name, string $name, array $args) | 
| 107 | 107 |      { | 
| 108 | 108 | self::$static_methods[$class_name] ??= []; | 
| 109 | -        if(isset(self::$static_methods[$class_name][$name])){ | |
| 109 | +        if (isset(self::$static_methods[$class_name][$name])) { | |
| 110 | 110 | $closure = self::$static_methods[$class_name][$name]; | 
| 111 | 111 | return ($closure->bindTo(null, $class_name))(...$args); | 
| 112 | 112 | } | 
| 113 | -        else{ | |
| 113 | +        else { | |
| 114 | 114 |              throw new Error("Call to undefined static method $class_name::$name()"); | 
| 115 | 115 | } | 
| 116 | 116 | } | 
| @@ -142,14 +142,14 @@ discard block | ||
| 142 | 142 | */ | 
| 143 | 143 | protected static function getClassTraits(string $class): array | 
| 144 | 144 |      { | 
| 145 | -        if(!class_exists($class)){ | |
| 145 | +        if (!class_exists($class)) { | |
| 146 | 146 |              throw new Exception("Class $class does not exist"); | 
| 147 | 147 | } | 
| 148 | 148 | $traits = []; | 
| 149 | 149 |          do { | 
| 150 | 150 | $traits = array_merge(class_uses($class), $traits); | 
| 151 | 151 | } | 
| 152 | - while($class = get_parent_class($class)); | |
| 152 | + while ($class = get_parent_class($class)); | |
| 153 | 153 | |
| 154 | 154 |          foreach ($traits as $trait) { | 
| 155 | 155 | $traits = array_merge(class_uses($trait), $traits); | 
| @@ -174,7 +174,7 @@ discard block | ||
| 174 | 174 | */ | 
| 175 | 175 | final public static function addMethod(...$_): void | 
| 176 | 176 |      { | 
| 177 | -        throw new Exception('Adding normal method to '. static::class . ' does not make sense. Did you mean addStaticMethod?'); | |
| 177 | +        throw new Exception('Adding normal method to '.static::class.' does not make sense. Did you mean addStaticMethod?'); | |
| 178 | 178 | } | 
| 179 | 179 | |
| 180 | 180 | } | 
| @@ -37,16 +37,13 @@ discard block | ||
| 37 | 37 | self::$methods[$class_name] ??= []; | 
| 38 | 38 |                  if(!self::classHasPrototypeMethod($class_name, $name)){ | 
| 39 | 39 | self::$methods[$class_name][$name] = $fun; | 
| 40 | - } | |
| 41 | -                else{ | |
| 40 | +                } else{ | |
| 42 | 41 |                      throw new Exception("Invalid method name provided for class '$class_name': method '$name' is already a Prototype"); | 
| 43 | 42 | } | 
| 44 | - } | |
| 45 | -            else{ | |
| 43 | +            } else{ | |
| 46 | 44 |                  throw new Exception("Invalid method name provided for class '$class_name': method '$name' already exists"); | 
| 47 | 45 | } | 
| 48 | - } | |
| 49 | -        else{ | |
| 46 | +        } else{ | |
| 50 | 47 |              throw new Exception("Invalid class provided: class '$class_name' is not Prototypeable"); | 
| 51 | 48 | } | 
| 52 | 49 | } | 
| @@ -64,16 +61,13 @@ discard block | ||
| 64 | 61 | self::$static_methods[$class_name] ??= []; | 
| 65 | 62 |                  if(!self::classHasPrototypeMethod($class_name, $name)){ | 
| 66 | 63 | self::$static_methods[$class_name][$name] = $fun; | 
| 67 | - } | |
| 68 | -                else{ | |
| 64 | +                } else{ | |
| 69 | 65 |                      throw new Exception("Invalid method name provided for class '$class_name': method '$name' is already a Prototype"); | 
| 70 | 66 | } | 
| 71 | - } | |
| 72 | -            else{ | |
| 67 | +            } else{ | |
| 73 | 68 |                  throw new Exception("Invalid method name provided for class '$class_name': method '$name' already exists"); | 
| 74 | 69 | } | 
| 75 | - } | |
| 76 | -        else{ | |
| 70 | +        } else{ | |
| 77 | 71 |              throw new Exception("Invalid class provided: class '$class_name' is not Prototypeable"); | 
| 78 | 72 | } | 
| 79 | 73 | } | 
| @@ -91,8 +85,7 @@ discard block | ||
| 91 | 85 |          if(isset(self::$methods[$class_name][$name])){ | 
| 92 | 86 | $closure = self::$methods[$class_name][$name]; | 
| 93 | 87 | return $closure->call($obj, ...$args); | 
| 94 | - } | |
| 95 | -        else{ | |
| 88 | +        } else{ | |
| 96 | 89 |              throw new Error("Call to undefined method $class_name::$name()"); | 
| 97 | 90 | } | 
| 98 | 91 | } | 
| @@ -109,8 +102,7 @@ discard block | ||
| 109 | 102 |          if(isset(self::$static_methods[$class_name][$name])){ | 
| 110 | 103 | $closure = self::$static_methods[$class_name][$name]; | 
| 111 | 104 | return ($closure->bindTo(null, $class_name))(...$args); | 
| 112 | - } | |
| 113 | -        else{ | |
| 105 | +        } else{ | |
| 114 | 106 |              throw new Error("Call to undefined static method $class_name::$name()"); | 
| 115 | 107 | } | 
| 116 | 108 | } | 
| @@ -4,7 +4,7 @@ | ||
| 4 | 4 | |
| 5 | 5 | use Closure; | 
| 6 | 6 | |
| 7 | -trait Prototypeable{ | |
| 7 | +trait Prototypeable { | |
| 8 | 8 | |
| 9 | 9 | /** | 
| 10 | 10 | * @param string $name |