Why does getNumber() cast to an int?
chrisfromredfin opened this issue · 4 comments
chrisfromredfin commented
Description
When setting data in Notion in a number field, I'm setting values like 13.75 and 4.25. When I look at the getProperties() in the debugger and see raw data I see my decimal value. But when I then call getNumber() it's casting to an int everywhere.
Steps to reproduce
- Create a Notion DB with a number column.
- Set a value in the number column that has a decimal.
- call ->getProperties() on the row.
- call ->getNumber() on the $properties['My number'] it seems to floor() the number.
Expected behavior
I would expect the value as a decimal.
Screenshots or output
https://github.com/brd6/notion-sdk-php/blob/main/src/Resource/Property/Value/NumberValueProperty.php
Environment details
PHP 8.1 in DDEV.
chrisfromredfin commented
brd6 commented
Thanks for reporting this! I'll add a fix for the decimal handling.
chrisfromredfin commented
(FWIW we just changed the casting-to-int to casting-to-float and that seems to work.)
brd6 commented
Fixed!