From 33d933c206454e63bbb0b1d669b08a3c57a6b0d9 Mon Sep 17 00:00:00 2001 From: Paul Rock Date: Tue, 21 Aug 2018 04:28:45 +0300 Subject: [PATCH] small simplification --- src/Config.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Config.php b/src/Config.php index 57db87f..4e08b98 100644 --- a/src/Config.php +++ b/src/Config.php @@ -35,7 +35,7 @@ class Config implements ConfigInterface { // Check if parameter in list of allowed parameters if (!array_key_exists($key, $array)) { - throw new Exception("Requested parameter \"$key\" not found in allowed list [" . implode(',', + throw new Exception("Requested parameter '$key' not found in allowed list [" . implode(',', array_keys($array)) . ']'); } } @@ -54,15 +54,12 @@ class Config implements ConfigInterface // Check of key in array $this->keyAllowed($name, self::ALLOWED); - // Get type of current variable $whatType = \gettype($value); - // Get allowed type of parameter - $type = self::ALLOWED[$name]; - $isType = 'is_' . $type; + $isType = self::ALLOWED[$name]; // Check what type has this value - if (!$isType($value)) { - throw new Exception("Parameter \"$name\" has wrong type \"$whatType\" but should be \"$type\""); + if ($whatType !== $isType) { + throw new Exception("Parameter '$name' has wrong type '$whatType'' but should be '$isType''"); } } catch (Exception $e) {