GeneratorManager: add typehints

This commit is contained in:
Dylan K. Taylor 2018-06-07 14:24:01 +01:00
parent 5eec683110
commit 96a4dbb7d8

View File

@ -38,7 +38,7 @@ final class GeneratorManager{
self::addGenerator(Nether::class, "nether"); self::addGenerator(Nether::class, "nether");
} }
public static function addGenerator($object, $name) : bool{ public static function addGenerator(string $object, string $name) : bool{
if(is_subclass_of($object, Generator::class) and !isset(self::$list[$name = strtolower($name)])){ if(is_subclass_of($object, Generator::class) and !isset(self::$list[$name = strtolower($name)])){
self::$list[$name] = $object; self::$list[$name] = $object;
@ -56,11 +56,11 @@ final class GeneratorManager{
} }
/** /**
* @param $name * @param string $name
* *
* @return string|Generator Name of class that extends Generator (not an actual Generator object) * @return string|Generator Name of class that extends Generator (not an actual Generator object)
*/ */
public static function getGenerator($name){ public static function getGenerator(string $name){
if(isset(self::$list[$name = strtolower($name)])){ if(isset(self::$list[$name = strtolower($name)])){
return self::$list[$name]; return self::$list[$name];
} }
@ -68,7 +68,7 @@ final class GeneratorManager{
return Normal::class; return Normal::class;
} }
public static function getGeneratorName($class){ public static function getGeneratorName(string $class) : string{
foreach(self::$list as $name => $c){ foreach(self::$list as $name => $c){
if($c === $class){ if($c === $class){
return $name; return $name;