• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

un-zero-un / Isocontent / 19910422417

03 Dec 2025 10:09PM UTC coverage: 93.906% (-0.6%) from 94.49%
19910422417

push

gha

339 of 361 relevant lines covered (93.91%)

128.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Bridge/Symfony/Form/DataTransformer/ASTToArrayTransformer.php
1
<?php
2

3
namespace Isocontent\Bridge\Symfony\Form\DataTransformer;
4

5
use Isocontent\AST\Node;
6
use Isocontent\AST\NodeList;
7
use Isocontent\Isocontent;
8
use Symfony\Component\Form\DataTransformerInterface;
9
use Symfony\Component\Form\Exception\TransformationFailedException;
10

11
/**
12
 * @implements DataTransformerInterface<NodeList|Node, array>
13
 */
14
final class ASTToArrayTransformer implements DataTransformerInterface
15
{
16
    public function __construct(
×
17
        private readonly Isocontent $isocontent,
18
    ) {
19
    }
×
20

21
    #[\Override]
×
22
    public function transform($value): ?array
23
    {
24
        if (!$value) {
×
25
            return null;
×
26
        }
27

28
        if (!$value instanceof NodeList) {
×
29
            throw new TransformationFailedException();
×
30
        }
31

32
        return $value->toArray();
×
33
    }
34

35
    /**
36
     * @psalm-suppress DocblockTypeContradiction
37
     */
38
    #[\Override]
×
39
    public function reverseTransform($value): NodeList|Node|null
40
    {
41
        if (null === $value) {
×
42
            return null;
×
43
        }
44

45
        if (!is_array($value)) {
×
46
            throw new TransformationFailedException();
×
47
        }
48

49
        return $this->isocontent->buildAST($value, 'array');
×
50
    }
51
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc