xolphin / xolphin-api-php

Xolphin API module for PHP
8 stars 16 forks source link

Feature/renew and request consistency #9

Closed webdevvie closed 4 years ago

webdevvie commented 6 years ago

Request assumes the $product value to be an integer. And the Renew class assumes it to be a Product. But this is not enforced in either with a type declaration or a check and this is inconsistent between the two.

Renew: https://github.com/xolphin/xolphin-api-php/blob/709c24efa6f33342799f1e3b1abd86d722e5044c/src/Requests/Renew.php#L78

Request: https://github.com/xolphin/xolphin-api-php/blob/709c24efa6f33342799f1e3b1abd86d722e5044c/src/Requests/Request.php#L85

Suggested solution: Instead of breaking the client for anyone currently using it in this manner(We just cast it to an object and that works for now). Allowing people to input an integer on the Renew&Request class constructor and checking in the getArray method by checking if it is an object or not and then either just placing the $this->product or $this->product->id into the array

This is what this pull request does.

An alternative could be to enforce the Product on both renew and request class constructors with a type declaration. This would be problematic for anyone already using this client.

ghost commented 4 years ago

Both classes are now using a consistent $productId variable