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

FluidTYPO3 / vhs / 30001290505

23 Jul 2026 10:57AM UTC coverage: 70.309% (-1.7%) from 72.022%
30001290505

push

github

NamelessCoder
[TER] 8.0.0

4819 of 6854 relevant lines covered (70.31%)

6.54 hits per line

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

96.77
/Classes/ViewHelpers/Iterator/ExplodeViewHelper.php
1
<?php
2
namespace FluidTYPO3\Vhs\ViewHelpers\Iterator;
3

4
/*
5
 * This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.md file that was distributed with this source code.
9
 */
10

11
use FluidTYPO3\Vhs\Core\ViewHelper\AbstractViewHelper;
12
use FluidTYPO3\Vhs\Traits\ArrayConsumingViewHelperTrait;
13
use FluidTYPO3\Vhs\Traits\TemplateVariableViewHelperTrait;
14
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
15

16
/**
17
 * Explode ViewHelper
18
 *
19
 * Explodes a string by $glue.
20
 */
21
class ExplodeViewHelper extends AbstractViewHelper
22
{
23
    use TemplateVariableViewHelperTrait;
24
    use ArrayConsumingViewHelperTrait;
25

26
    /**
27
     * @var boolean
28
     */
29
    protected $escapeChildren = false;
30

31
    /**
32
     * @var boolean
33
     */
34
    protected $escapeOutput = false;
35

36
    public function initializeArguments(): void
37
    {
38
        $this->registerArgument('content', 'string', 'String to be exploded by glue');
3✔
39
        $this->registerArgument(
3✔
40
            'glue',
3✔
41
            'string',
3✔
42
            'String "glue" that separates values. If you need a constant (like PHP_EOL), use v:const to read it.',
3✔
43
            false,
3✔
44
            ','
3✔
45
        );
3✔
46
        $this->registerArgument(
3✔
47
            'limit',
3✔
48
            'int',
3✔
49
            'If limit is set and positive, the returned array will contain a maximum of limit elements with the last ' .
3✔
50
            'element containing the rest of string. If the limit parameter is negative, all components except the ' .
3✔
51
            'last-limit are returned. If the limit parameter is zero, then this is treated as 1.',
3✔
52
            false,
3✔
53
            PHP_INT_MAX
3✔
54
        );
3✔
55
        $this->registerAsArgument();
3✔
56
    }
57

58
    /**
59
     * @return mixed
60
     */
61
    public static function renderStatic(
62
        array $arguments,
63
        \Closure $renderChildrenClosure,
64
        RenderingContextInterface $renderingContext
65
    ) {
66
        /** @var string $content */
67
        $content = $arguments['content'];
6✔
68
        /** @var string|null $as */
69
        $as = $arguments['as'];
6✔
70
        if (empty($as)) {
6✔
71
            $content = $content ?? $renderChildrenClosure();
×
72
        }
73
        /** @var string&non-empty-string $glue */
74
        $glue = $arguments['glue'];
6✔
75
        /** @var int $limit */
76
        $limit = $arguments['limit'] ?? PHP_INT_MAX;
6✔
77
        $output = explode($glue, (string) $content, $limit);
6✔
78
        return static::renderChildrenWithVariableOrReturnInputStatic(
6✔
79
            $output,
6✔
80
            $as,
6✔
81
            $renderingContext,
6✔
82
            $renderChildrenClosure
6✔
83
        );
6✔
84
    }
85
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc