From 22431f8ce6749937b8d7379de8f21841d09a38a5 Mon Sep 17 00:00:00 2001 From: Jens Schulze Date: Wed, 21 Oct 2015 16:12:06 +0200 Subject: [PATCH] fix(JsonObject): fix error message for unknown method --- src/Error/Message.php | 2 +- src/Model/Common/JsonObject.php | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Error/Message.php b/src/Error/Message.php index 551b1cb2e0..e1174ed197 100644 --- a/src/Error/Message.php +++ b/src/Error/Message.php @@ -25,7 +25,7 @@ class Message const AUTHENTICATION_FAIL = 'Authentication failed: %s'; - const UNKNOWN_METHOD = 'Unknown method: %s (unknown field: %s)'; + const UNKNOWN_METHOD = 'Unknown method: %s'; const UNKNOWN_FIELD = 'Unknown field: "%s" - called: %s(%s)'; const WRONG_TYPE = 'Wrong type for field "%s". Expected %s.'; const EXPECTS_PARAMETER = 'Excepts parameter "%s" to be %s, null given.'; diff --git a/src/Model/Common/JsonObject.php b/src/Model/Common/JsonObject.php index 4addd9e7ab..3dceefef12 100644 --- a/src/Model/Common/JsonObject.php +++ b/src/Model/Common/JsonObject.php @@ -51,9 +51,13 @@ public function __call($method, $arguments) $field = lcfirst(substr($method, 3)); if (!$this->hasField($field)) { - throw new \BadMethodCallException( - sprintf(Message::UNKNOWN_FIELD, $field, $method, implode(', ', $arguments)) - ); + if ($action == 'get' || $action == 'set') { + throw new \BadMethodCallException( + sprintf(Message::UNKNOWN_FIELD, $field, $method, implode(', ', $arguments)) + ); + } else { + throw new \BadMethodCallException(sprintf(Message::UNKNOWN_METHOD, $method, $field)); + } } switch ($action) { case 'get':