Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
AmicronDecimalType
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 3
30
0.00% covered (danger)
0.00%
0 / 1
 convertToPHPValue
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 convertToDatabaseValue
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 requiresSQLCommentHint
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Satag\AmicronEntityBundle\Doctrine;
6
7use Doctrine\DBAL\Platforms\AbstractPlatform;
8use Doctrine\DBAL\Types\DecimalType;
9
10/**
11 * Amicron decimal type: preserves full string precision for Firebird DECIMAL(15,6) columns.
12 *
13 * Doctrine's default DecimalType returns a string, but this type makes the contract
14 * explicit and ensures null-safety. Using string (not float) avoids IEEE 754 rounding
15 * errors on financial and weight values (e.g. ENDBETRAG, GEWICHT, WAEHRUNGSKURS).
16 *
17 * Usage in entity mapping:
18 *   #[ORM\Column(name: 'endbetrag', type: 'amicron_decimal', precision: 15, scale: 6, nullable: true)]
19 *   protected ?string $endbetrag = null;
20 */
21class AmicronDecimalType extends DecimalType
22{
23    public const NAME = 'amicron_decimal';
24
25    #[\Override]
26    public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?string
27    {
28        if ($value === null) {
29            return null;
30        }
31
32        return (string) $value;
33    }
34
35    #[\Override]
36    public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?string
37    {
38        if ($value === null) {
39            return null;
40        }
41
42        return (string) $value;
43    }
44
45    #[\Override]
46    public function requiresSQLCommentHint(AbstractPlatform $platform): bool
47    {
48        return true;
49    }
50}