- Is assoconnect/absolute-percent-value-bundle a Laravel package or a Symfony bundle?
- It is a Symfony bundle, even though it is often listed alongside Laravel Composer packages. The package name ends in -Bundle, its changelog tracks Symfony 6 and Symfony 7 support, and it relies on the Symfony service-container DI extension and the Symfony Serializer. Nothing in it auto-registers in Laravel, so a Laravel app would use the AbsolutePercentValue class directly rather than adopt it as a framework integration.
- How do I install absolute-percent-value-bundle with Composer?
- Run composer require assoconnect/absolute-percent-value-bundle. In a Symfony application you also register the bundle in your bundles configuration, which is where the DI extension and serializer wiring come from. In a Laravel application there is no bundle registration step, so you would only be pulling in the value object class. Note that v1.4.0 dropped support for PHP versions below 8.2.
- What does AbsolutePercentValue actually represent?
- It is a small value object with exactly two attributes: a type that is either PERCENT or ABSOLUTE, and a value that is a positive numeric string. When the type is PERCENT, the value must be less than 10000, meaning the scale is fixed-point with 10000 equal to 100.00 percent. That is the whole contract, so it works as a typed carrier for a dual-mode scalar rather than a calculation helper.
- Why does it store the value as a string instead of a float?
- Keeping the value as a numeric string avoids binary floating-point drift on money-adjacent math, which is a common source of rounding bugs when percentages are stored as floats. The object also restricts the value to positive numbers and bounds percent values to a fixed scale. This makes it a useful contract at an API boundary, where free-text numeric input often passes validation but violates domain rules.
- Why can't I represent a 100% discount with this package?
- The documented invariant says a percent value must be less than 10000, so 10000, which represents 100.00 percent, is rejected. That means a 100 percent discount, a 100 percent tax rate, or a full write-off cannot be expressed with this value object. Confirm whether that ceiling is intentional in the source before relying on it for promotions or tax logic.
- Does it calculate or apply percentages to amounts?
- No. There is no calculate(), apply(), applyTo(Money), or toDecimal() method documented, and no rounding policy or currency awareness. Your code is expected to branch on the type and perform the arithmetic itself. The package gives you storage and contract correctness, not calculation correctness.
- Which PHP and Symfony versions are supported?
- The changelog shows support for Symfony 6 and Symfony 7, and v1.4.0 removed support for PHP versions below 8.2. The PHP floor has moved without deprecation ceremony in the past, so pin the package version in Composer and test upgrades. Because the package surface is tiny, adapting to a version bump is usually trivial.
- What is the serialized JSON wire format for AbsolutePercentValue?
- Denormalization runs through the Symfony Serializer, so the wire representation follows the object's two attributes, for example {"type":"PERCENT","value":"1500"}. Check the source for the exact property names and whether normalization is supported symmetrically. Consider whether you want to expose that shape to API clients or keep it as an internal representation.
- Can I persist AbsolutePercentValue with Eloquent or Doctrine?
- There is no documented Doctrine DBAL type or embeddable mapping, so persistence is left to you. The usual approach is two columns, one for the type and one for the string value, wrapped in a custom Eloquent cast or Doctrine embeddable. That keeps the constructor invariants enforced on the way in and out of the database.
- Is this package actively maintained, and should I depend on it?
- It has very low adoption, around one star and no dependents, and it is published by a single agency with a maintenance-only release cadence of Rector, PHPStan, and framework version updates. Quality signals are good for its size, including a build badge, a SonarCloud gate, and tests with data providers. Since the code is only roughly 40 to 120 lines, the safest path for a Laravel team is often to replicate the value object pattern in-house rather than take the dependency.