Skip to content

Conversation

@mschadegg
Copy link
Member

This pull request introduces a new attribute for formatting float precision in API resources, applies it to the discountPercentage property in ProductLine, and makes a minor fix to an exception message. Additionally, it updates dependencies in composer.json. The most important changes are:

New Feature: Float Precision Attribute

  • Added the FloatPrecision attribute in src/Attributes/Resources/Properties/ApiFormatting/FloatPrecision.php, allowing properties to be automatically rounded to a specified precision when formatted for the API.

Usage of Float Precision

  • Applied the #[FloatPrecision(2)] attribute to the discountPercentage property in the ProductLine DTO, ensuring this value is rounded to two decimal places. [1] [2]

Bug Fix

  • Corrected the exception message in ResourceToPrimaryKey to reference the correct class name.

Dependency Updates

  • Added psr/log as a required dependency in composer.json to ensure compatibility with logging interfaces.

mschadegg and others added 5 commits August 20, 2025 10:21
Add PSR logger as a dependency.

This allows the application to utilize a standard logging interface,
improving interoperability with other logging libraries and frameworks.
Updates the exception message to reflect the correct attribute name.

The previous message incorrectly referred to 'ResourceToArray'
instead of 'ResourceToPrimaryKey', leading to potential confusion
when debugging.
Adds an attribute to format float values with a specific precision when interacting with the API.

This ensures consistent and accurate data representation by rounding float values to the desired precision level.
Ensures the discount percentage is formatted with a precision of 2 when sent to the API.
@mschadegg mschadegg requested a review from Copilot August 20, 2025 09:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces a new FloatPrecision attribute for automatic rounding of float values in API responses, applies it to the discountPercentage property in ProductLine, and includes a bug fix and dependency update.

  • Added a new FloatPrecision attribute that rounds float values to specified decimal places
  • Applied the attribute to ProductLine.discountPercentage for 2-decimal precision
  • Fixed an incorrect exception message in ResourceToPrimaryKey

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/Attributes/Resources/Properties/ApiFormatting/FloatPrecision.php New attribute class for rounding float values to specified precision
src/DTOs/Invoice/ProductLine.php Applied FloatPrecision attribute to discountPercentage property
src/Attributes/Resources/Properties/ApiFormatting/ResourceToPrimaryKey.php Fixed exception message to reference correct class name
composer.json Added psr/log dependency

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

mschadegg and others added 3 commits August 20, 2025 11:14
…sion.php

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…sion.php

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Adds a missing curly brace to the `FloatPrecision` class.

This resolves a syntax error and ensures the class functions as intended.
@mschadegg mschadegg merged commit 47b9472 into main Aug 20, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants