CristalTeam / php-api-wrapper

:rainbow: Work with APIs like with Laravel Eloquent or Doctrine (no longer a dream)
MIT License
117 stars 32 forks source link

Method call needs to sanitize method name #9

Open guice opened 4 years ago

guice commented 4 years ago

In this piece of code:

https://github.com/CristalTeam/php-api-wrapper/blob/4f52883e250b8ea4b38c7c6b09d0ead6a0c562cb/src/Api.php#L48-L53

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.