CristalTeam/php-api-wrapper

Method call needs to sanitize method name

guice opened this issue · 0 comments

guice commented

In this piece of code:

public function __call($name, $arguments)
{
if (method_exists($this, $name)) {
return $this->$name(...$arguments);
}

You check for a method based on the entity attribute name. If the entity is named with a _ or -, there isn't a way to properly overload this.

For example:

$entity = 'entity-attribute'

The proper endpoint is: /api/entity-attribute/

But you can't have a method by the name of getEntity-Attribute.

The solution is to PascalCase the entity name before checking for a get method.