Skip to content

Commit

Permalink
Implemented check if method exists
Browse files Browse the repository at this point in the history
So models won't break when Acumulus updates their API's with
more responses
  • Loading branch information
Wouter0100 committed Apr 11, 2018
1 parent 50b9f45 commit be8a1c7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Thalent/AcumulusPhp/Parsers/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ public function buildModel($item, $model)
}

$fieldName = 'set' . ucfirst($name);
// Call the function by the array key name
$model->$fieldName($value);

if (method_exists($model, $fieldName)) {
// Call the function by the array key name
$model->$fieldName($value);
}

}

Expand Down

0 comments on commit be8a1c7

Please sign in to comment.