Schoolrunner / oauth2-clever

OAuth2 Clever Client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Resource owner factory is overly complex

shadowhand opened this issue · comments

createResourceOwner makes a fully qualified class name when all it really needs to do is create a local class name, since Clever.php and CleverUser classes are in the same namespace:

$userClass = 'Clever' . ucfirst($response['type']);

FWIW, I don't advocate this kind of mapping and would recommend using separate, injected factory class instead.

I agree with your first comment. full path not needed.

I am not sure exactly what you mean or the purpose regarding the injected factory class comment. Wouldnt it just be moving this logic to another file? Maybe I am confused so if you could explain that would be helpful!

Having a factory as a constructor argument would allow end users to add additional user types without having to overload the class. It would also allow users to overload the existing user types without having to create an extension of the provider.

So yes, it does move logic to another file, and the important thing is that class can be replaced entirely or partially to modify behavior without altering the behavior of the client class itself.

Thanks for the explanation. I put out a pr to address your issues including this one.