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

CPS-IT / handlebars-forms / 23286029549

19 Mar 2026 08:20AM UTC coverage: 0.0%. Remained the same
23286029549

push

github

eliashaeussler
[FEATURE] Introduce `ViewModelCollection`

0 of 63 new or added lines in 16 files covered. (0.0%)

2 existing lines in 2 files now uncovered.

0 of 779 relevant lines covered (0.0%)

0.0 hits per line

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

0.0
/Classes/Domain/Renderable/ViewModel/ViewModelCollection.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\Renderable\ViewModel;
19

20
use CPSIT\Typo3HandlebarsForms\Exception;
21
use TYPO3\CMS\Fluid;
22
use TYPO3Fluid\Fluid as FluidStandalone;
23

24
/**
25
 * ViewModelCollection
26
 *
27
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
28
 * @license GPL-2.0-or-later
29
 *
30
 * @implements \IteratorAggregate<ViewModel>
31
 */
32
final readonly class ViewModelCollection implements \Countable, \IteratorAggregate
33
{
34
    /**
35
     * @param non-empty-list<ViewModel> $viewModels
36
     */
NEW
37
    public function __construct(
×
38
        public array $viewModels,
NEW
39
    ) {}
×
40

NEW
41
    public static function createSingle(
×
42
        Fluid\Core\Rendering\RenderingContext $renderingContext,
43
        mixed $content = null,
44
        FluidStandalone\Core\ViewHelper\TagBuilder $tag = new FluidStandalone\Core\ViewHelper\TagBuilder(),
45
    ): self {
NEW
46
        $viewModel = new ViewModel($renderingContext, $content, $tag);
×
47

NEW
48
        return new self([$viewModel]);
×
49
    }
50

51
    /**
52
     * @throws Exception\CollectionContainsMultipleViewModels
53
     */
NEW
54
    public function toViewModel(): ViewModel
×
55
    {
NEW
56
        if (!$this->hasMultipleViewModels()) {
×
NEW
57
            return $this->viewModels[0];
×
58
        }
59

NEW
60
        throw new Exception\CollectionContainsMultipleViewModels();
×
61
    }
62

NEW
63
    public function hasMultipleViewModels(): bool
×
64
    {
NEW
65
        return count($this->viewModels) > 1;
×
66
    }
67

NEW
68
    public function count(): int
×
69
    {
NEW
70
        return count($this->viewModels);
×
71
    }
72

NEW
73
    public function getIterator(): \Traversable
×
74
    {
NEW
75
        return new \ArrayIterator($this->viewModels);
×
76
    }
77
}
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