Permission: Throw exception on unknown values in getByName()

Previously, writing wrong values into plugin.yml for permission defaults would cause the permission to be silently denied to everyone.
This commit is contained in:
Dylan K. Taylor 2018-12-01 15:56:44 +00:00
parent 75482124f2
commit acd7c9b336

View File

@ -42,6 +42,8 @@ class Permission{
* @param bool|string $value
*
* @return string
*
* @throws \InvalidArgumentException
*/
public static function getByName($value) : string{
if(is_bool($value)){
@ -70,10 +72,11 @@ class Permission{
case "true":
return self::DEFAULT_TRUE;
default:
case "false":
return self::DEFAULT_FALSE;
}
throw new \InvalidArgumentException("Unknown permission default name \"$value\"");
}
/**