bluerocktel / sellsy-client

A lightweight PHP client to query the Sellsy API V2 (Sellsy API connector)
https://bluerocktel.com
MIT License
8 stars 6 forks source link

Code refacto #16

Open andrelec1 opened 6 months ago

andrelec1 commented 6 months ago

https://github.com/bluerocktel/sellsy-client/blob/2cd01851855c29c4c10715fcd487e4a6af7b1ef1/src/Core/Request.php#L154

This look like bad code for me... But this is not the first time i see this in random php project.

So some one can explain why using this pattern ?

tgeorgel commented 6 months ago

Are you talking about the __call() magic method or the inner switch statement ?

andrelec1 commented 6 months ago

I talk about the inner switch ....

The switch case statement is here to avoid the poor perf of call_user_func_array ... But all this code can be replaced by this single line : $this->req = $this->req->$method(...$args);

( Argument Unpacking have been implemented in php 5.6 ... lib require php 7.4 so... why not using it ? )

tgeorgel commented 6 months ago

Well it is just a matter of habit, unpacking is indeed a nicest way to do so :)