22digital /
laravel-cashier-fastspring
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * This class helps to reach the Fastspring class with Laravel config and static |
||
| 4 | * methods. |
||
| 5 | * |
||
| 6 | * @author Bilal Gultekin <[email protected]> |
||
| 7 | * @version 0.1: |
||
| 8 | * @copyright 2019 22 Digital |
||
| 9 | * @license MIT |
||
| 10 | * @see https://docs.fastspring.com/integrating-with-fastspring/fastspring-api |
||
| 11 | */ |
||
| 12 | |||
| 13 | namespace TwentyTwoDigital\CashierFastspring\Fastspring; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * This class describes the Fastspring implementation. |
||
| 17 | */ |
||
| 18 | class Fastspring |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * Instance of Fastspring class. |
||
| 22 | * |
||
| 23 | * @var array |
||
| 24 | */ |
||
| 25 | public static $instance; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Static method. |
||
| 29 | * |
||
| 30 | * It is not useful to construct this Fastspring class everytime. This helps |
||
| 31 | * to construct this class with the current config. if there is not any |
||
| 32 | * constructed instance then construct and save it to self::$instance |
||
| 33 | * |
||
| 34 | * @param string $method The method |
||
| 35 | * @param array $parameters The parameters for username and password |
||
| 36 | * |
||
| 37 | * @return self |
||
| 38 | */ |
||
| 39 | 21 | public static function __callStatic($method, $parameters) |
|
| 40 | { |
||
| 41 | 21 | if (!self::$instance) { |
|
|
0 ignored issues
–
show
|
|||
| 42 | 1 | $username = (getenv('FASTSPRING_USERNAME') ?: config('services.fastspring.username')); |
|
| 43 | 1 | $password = (getenv('FASTSPRING_PASSWORD') ?: config('services.fastspring.password')); |
|
| 44 | |||
| 45 | 1 | self::$instance = new ApiClient($username, $password); |
|
|
0 ignored issues
–
show
It seems like
new TwentyTwoDigital\Cas...t($username, $password) of type TwentyTwoDigital\Cashier...ng\Fastspring\ApiClient is incompatible with the declared type array of property $instance.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||
| 46 | } |
||
| 47 | |||
| 48 | 21 | return call_user_func_array([self::$instance, $method], $parameters); |
|
| 49 | } |
||
| 50 | } |
||
| 51 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.