Webador / sendcloud

Provides a PHP client to interact with the SendCloud API in an object-oriented way.
MIT License
16 stars 15 forks source link

Fix distorted min_weigth and max_height #27

Closed Valerie-Tylski-Vincent closed 10 months ago

Valerie-Tylski-Vincent commented 11 months ago

https://github.com/Webador/sendcloud/blob/81dbffecf1c332ac5ca296e86d7799ac877c9e97/src/Model/ShippingMethod.php#L17

Using (int) in the result of ShippingMethod::fromData() distorts the result of the min_weight and max_weight in some cases. Indeed, the result of (int)(1.001*1000) is 1000, while we expect to have 1001.

To avoid this, it could be possible to combine intval() and ceil(), like this:

intval(ceil($data['min_weight'] * 1000)),
intval(ceil($data['max_weight'] * 1000)),