Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
fix(JsonObject): fix error message for unknown method
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Schulze committed Oct 21, 2015
1 parent d2c01d5 commit 22431f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Error/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down
10 changes: 7 additions & 3 deletions src/Model/Common/JsonObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down

0 comments on commit 22431f8

Please # to comment.