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

CPS-IT / handlebars-forms / 23841311591

01 Apr 2026 09:16AM UTC coverage: 0.593% (-0.06%) from 0.654%
23841311591

push

github

web-flow
Merge pull request #19 from CPS-IT/feature/summary-page

0 of 115 new or added lines in 4 files covered. (0.0%)

1 existing line in 1 file now uncovered.

7 of 1181 relevant lines covered (0.59%)

0.02 hits per line

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

0.0
/Classes/Domain/ViewModel/FormValueViewModel.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "handlebars_forms".
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17

18
namespace CPSIT\Typo3HandlebarsForms\Domain\ViewModel;
19

20
use CPSIT\Typo3HandlebarsForms\Exception;
21
use TYPO3\CMS\Form;
22

23
/**
24
 * FormValueContext
25
 *
26
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
27
 * @license GPL-2.0-or-later
28
 *
29
 * @extends \ArrayObject<string|int, mixed>
30
 */
31
final class FormValueViewModel extends \ArrayObject implements CompositeViewModel
32
{
NEW
33
    public function __construct(
×
34
        public readonly Form\Domain\Model\FormElements\FormElementInterface $element,
35
        public readonly mixed $value,
36
        public readonly mixed $processedValue = null,
37
        public readonly bool $isMultiValue = false,
38
        public readonly bool $isSection = false,
39
    ) {
NEW
40
        parent::__construct([
×
NEW
41
            'value' => $this->value,
×
NEW
42
            'processedValue' => $this->processedValue,
×
NEW
43
            'isMultiValue' => $this->isMultiValue,
×
NEW
44
            'isSection' => $this->isSection,
×
NEW
45
        ]);
×
46
    }
47

48
    /**
49
     * @param array<string, mixed> $context
50
     * @throws Exception\FormValueContextIsInvalid
51
     */
NEW
52
    public static function fromArray(array $context): self
×
53
    {
NEW
54
        $element = $context['element'] ?? null;
×
NEW
55
        $value = $context['value'] ?? null;
×
NEW
56
        $processedValue = $context['processedValue'] ?? null;
×
NEW
57
        $isMultiValue = $context['isMultiValue'] ?? false;
×
NEW
58
        $isSection = $context['isSection'] ?? false;
×
59

NEW
60
        if (!($element instanceof Form\Domain\Model\FormElements\FormElementInterface)) {
×
NEW
61
            throw new Exception\FormValueContextIsInvalid();
×
62
        }
63

NEW
64
        if (is_scalar($isMultiValue)) {
×
NEW
65
            $isMultiValue = (bool)$isMultiValue;
×
66
        } else {
NEW
67
            $isMultiValue = false;
×
68
        }
69

NEW
70
        if (is_scalar($isSection)) {
×
NEW
71
            $isSection = (bool)$isSection;
×
72
        } else {
NEW
73
            $isSection = false;
×
74
        }
75

NEW
76
        return new self($element, $value, $processedValue, $isMultiValue, $isSection);
×
77
    }
78

NEW
79
    public function getRenderable(): Form\Domain\Model\FormElements\FormElementInterface
×
80
    {
NEW
81
        return $this->element;
×
82
    }
83

NEW
84
    public function getChildren(): array
×
85
    {
NEW
86
        if (!is_array($this->value) || !is_array($this->processedValue)) {
×
NEW
87
            return [];
×
88
        }
89

NEW
90
        $children = [];
×
91

NEW
92
        foreach ($this->processedValue as $key => $processedValue) {
×
NEW
93
            $value = $this->value[$key] ?? null;
×
NEW
94
            $children[] = new self($this->element, $value, $processedValue);
×
95
        }
96

NEW
97
        return $children;
×
98
    }
99
}
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