shusaura85 / fancourier-api

PHP library to work with the new Fan Courier API v2.0 (selfawb.ro / api.fancourier.ro)
MIT License
21 stars 9 forks source link

Wrong condition on GetCosts::setPaymentType() causes exception #5

Closed stefanbutura closed 9 months ago

stefanbutura commented 9 months ago

See https://github.com/shusaura85/fancourier-api/blob/main/src/Fancourier/Request/GetCosts.php#L109

The condition will always be true and the exception will always be thrown.

if ($paymentType != self::TYPE_RECIPIENT || $paymentType != self::TYPE_SENDER) {
  throw new \InvalidArgumentException("Invalid paymentType value");
}

should probably be

if ($paymentType != self::TYPE_RECIPIENT && $paymentType != self::TYPE_SENDER) {
  throw new \InvalidArgumentException("Invalid paymentType value");
}
shusaura85 commented 9 months ago

Thanks for the report.
I fixed the code and will push v2.0.2 in a few minutes

Edit: v2.0.2 is now live