• 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

92.31
/Classes/ViewHelpers/Math/AbstractSingleMathViewHelper.php
1
<?php
2
namespace FluidTYPO3\Vhs\ViewHelpers\Math;
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\Utility\ErrorUtility;
14
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
15

16
/**
17
 * Base class: Math ViewHelpers operating on one number or an
18
 * array of numbers.
19
 */
20
abstract class AbstractSingleMathViewHelper extends AbstractViewHelper
21
{
22
    use ArrayConsumingViewHelperTrait;
23

24
    /**
25
     * @var boolean
26
     */
27
    protected $escapeChildren = false;
28

29
    /**
30
     * @var boolean
31
     */
32
    protected $escapeOutput = false;
33

34
    public function initializeArguments(): void
35
    {
36
        $this->registerArgument('a', 'mixed', 'First number for calculation');
27✔
37
        $this->registerArgument(
27✔
38
            'fail',
27✔
39
            'boolean',
27✔
40
            'If TRUE, throws an Exception if argument "a" is not specified and no child content or inline argument ' .
27✔
41
            'is found. Usually okay to use a NULL value (as integer zero).',
27✔
42
            false,
27✔
43
            false
27✔
44
        );
27✔
45
    }
46

47
    /**
48
     * @return mixed
49
     */
50
    public static function renderStatic(
51
        array $arguments,
52
        \Closure $renderChildrenClosure,
53
        RenderingContextInterface $renderingContext
54
    ) {
55
        /** @var array|numeric-string|numeric|null $value */
56
        $value = $arguments['a'] ?? $renderChildrenClosure();
30✔
57
        if (null === $value && $arguments['fail']) {
30✔
58
            ErrorUtility::throwViewHelperException('Required argument "a" was not supplied', 1237823699);
×
59
        }
60
        return static::calculateAction($value, $arguments);
30✔
61
    }
62

63
    /**
64
     * @param numeric|numeric-string|array|iterable|null $a
65
     * @return numeric|array
66
     */
67
    abstract protected static function calculateAction($a, array $arguments = []);
68
}
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