Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
AmicronBooleanIntType
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 2
30
0.00% covered (danger)
0.00%
0 / 1
 convertToDatabaseValue
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 convertToPHPValue
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3declare(strict_types=1);
4
5namespace Satag\AmicronEntityBundle\Doctrine;
6
7use Doctrine\DBAL\Platforms\AbstractPlatform;
8use Doctrine\DBAL\Types\BooleanType;
9
10class AmicronBooleanIntType extends BooleanType
11{
12    /**
13     * @return string
14     */
15    #[\Override]
16    public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
17    {
18        if ($value === true) {
19            return '1';
20        }
21
22        return '0';
23    }
24
25    /**
26     * @return bool|null
27     */
28    #[\Override]
29    public function convertToPHPValue($value, AbstractPlatform $platform): mixed
30    {
31        if ($value === 1) {
32            return true;
33        } elseif ($value === 0) {
34            return false;
35        }
36
37        return $platform->convertFromBoolean($value);
38    }
39}