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

FluidTYPO3 / vhs / 13566190336

27 Feb 2025 12:18PM UTC coverage: 72.127% (-0.6%) from 72.746%
13566190336

push

github

NamelessCoder
[TER] 7.1.0

5649 of 7832 relevant lines covered (72.13%)

20.01 hits per line

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

95.45
/Classes/ViewHelpers/Iterator/ImplodeViewHelper.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\Traits\ArrayConsumingViewHelperTrait;
12
use FluidTYPO3\Vhs\Traits\CompileWithRenderStatic;
13
use FluidTYPO3\Vhs\Traits\TemplateVariableViewHelperTrait;
14
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
15
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
16

17
/**
18
 * Implode ViewHelper
19
 *
20
 * Implodes an array or array-convertible object by $glue.
21
 */
22
class ImplodeViewHelper extends AbstractViewHelper
23
{
24
    use TemplateVariableViewHelperTrait;
25
    use ArrayConsumingViewHelperTrait;
26
    use CompileWithRenderStatic;
27

28
    /**
29
     * @var boolean
30
     */
31
    protected $escapeChildren = false;
32

33
    /**
34
     * @var boolean
35
     */
36
    protected $escapeOutput = false;
37

38
    public function initializeArguments(): void
39
    {
40
        parent::initializeArguments();
7✔
41

42
        $this->registerArgument('content', 'array', 'Array or array-convertible object to be imploded by glue');
7✔
43
        $this->registerArgument(
7✔
44
            'glue',
7✔
45
            'string',
7✔
46
            'String used as glue in the string to be exploded. To read a constant (like PHP_EOL) use v:const.',
7✔
47
            false,
7✔
48
            ','
7✔
49
        );
7✔
50
        $this->registerAsArgument();
7✔
51
    }
52

53
    /**
54
     * @return mixed
55
     */
56
    public static function renderStatic(
57
        array $arguments,
58
        \Closure $renderChildrenClosure,
59
        RenderingContextInterface $renderingContext
60
    ) {
61
        /** @var string|null $as */
62
        $as = $arguments['as'];
14✔
63
        /** @var array $content */
64
        $content = !empty($as)
14✔
65
            ? $arguments['content']
×
66
            : ($arguments['content'] ?? $renderChildrenClosure());
14✔
67
        /** @var string $glue */
68
        $glue = $arguments['glue'];
14✔
69
        $output = implode($glue, $content);
14✔
70
        return static::renderChildrenWithVariableOrReturnInputStatic(
14✔
71
            $output,
14✔
72
            $as,
14✔
73
            $renderingContext,
14✔
74
            $renderChildrenClosure
14✔
75
        );
14✔
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