• 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

75.0
/Classes/ViewHelpers/Format/Json/DecodeViewHelper.php
1
<?php
2
namespace FluidTYPO3\Vhs\ViewHelpers\Format\Json;
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\Utility\ErrorUtility;
13
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
14

15
/**
16
 * Converts the JSON encoded argument into a PHP variable.
17
 */
18
class DecodeViewHelper extends AbstractViewHelper
19
{
20
    public function initializeArguments(): void
21
    {
22
        $this->registerArgument('json', 'string', 'JSON string to decode');
3✔
23
    }
24

25
    /**
26
     * @return mixed
27
     */
28
    public static function renderStatic(
29
        array $arguments,
30
        \Closure $renderChildrenClosure,
31
        RenderingContextInterface $renderingContext
32
    ) {
33
        /** @var string $json */
34
        $json = $arguments['json'] ?? $renderChildrenClosure();
3✔
35
        if (empty($json)) {
3✔
36
            return null;
×
37
        }
38
        $value = json_decode($json, true);
3✔
39

40
        if (JSON_ERROR_NONE !== json_last_error()) {
3✔
41
            ErrorUtility::throwViewHelperException('The provided argument is invalid JSON.', 1358440054);
×
42
        }
43

44
        return $value;
3✔
45
    }
46
}
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