• 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.86
/Classes/ViewHelpers/Media/SizeViewHelper.php
1
<?php
2
namespace FluidTYPO3\Vhs\ViewHelpers\Media;
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 TYPO3\CMS\Core\Utility\GeneralUtility;
13
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
14
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception;
15

16
/**
17
 * Returns the size of the provided file in bytes.
18
 */
19
class SizeViewHelper extends AbstractViewHelper
20
{
21
    /**
22
     * @var boolean
23
     */
24
    protected $escapeChildren = false;
25

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

31
    public function initializeArguments(): void
32
    {
33
        $this->registerArgument('path', 'string', 'Path to the file to determine size for.');
3✔
34
    }
35

36
    /**
37
     * @return integer
38
     */
39
    public static function renderStatic(
40
        array $arguments,
41
        \Closure $renderChildrenClosure,
42
        RenderingContextInterface $renderingContext
43
    ) {
44
        /** @var string $path */
45
        $path = $arguments['path'] ?? $renderChildrenClosure();
12✔
46

47
        if (null === $path) {
12✔
48
            return 0;
3✔
49
        }
50

51
        $file = GeneralUtility::getFileAbsFileName($path);
9✔
52

53
        if (!file_exists($file) || is_dir($file)) {
9✔
54
            throw new Exception(
6✔
55
                'Cannot determine size of "' . $file . '". File does not exist or is a directory.',
6✔
56
                1356953963
6✔
57
            );
6✔
58
        }
59

60
        $size = filesize($file);
3✔
61

62
        if (false === $size) {
3✔
63
            throw new Exception('Cannot determine size of "' . $file . '".', 1356954032);
×
64
        }
65

66
        return $size;
3✔
67
    }
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