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

CPS-IT / handlebars / 26435956943

26 May 2026 06:22AM UTC coverage: 89.785% (-0.04%) from 89.827%
26435956943

push

github

web-flow
Merge pull request #581 from CPS-IT/feature/join-separator

[FEATURE] Make separator configurable in `join` helper

3 of 4 new or added lines in 1 file covered. (75.0%)

1459 of 1625 relevant lines covered (89.78%)

7.18 hits per line

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

81.82
/Classes/Renderer/Helper/JoinHelper.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "handlebars".
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17

18
namespace CPSIT\Typo3Handlebars\Renderer\Helper;
19

20
use CPSIT\Typo3Handlebars\Attribute;
21
use DevTheorem\Handlebars;
22

23
/**
24
 * JoinHelper
25
 *
26
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
27
 * @license GPL-2.0-or-later
28
 */
29
#[Attribute\AsHelper('join')]
30
final readonly class JoinHelper implements Helper
31
{
32
    public function render(Handlebars\HelperOptions $options, mixed ...$parts): string
3✔
33
    {
34
        $separator = $options->hash['separator'] ?? '';
3✔
35

36
        if (!is_string($separator)) {
3✔
NEW
37
            $separator = '';
×
38
        }
39

40
        return implode($separator, array_filter(array_map($this->convertToString(...), $parts), is_string(...)));
3✔
41
    }
42

43
    private function convertToString(mixed $value): ?string
3✔
44
    {
45
        if (is_scalar($value)) {
3✔
46
            return (string)$value;
3✔
47
        }
48

49
        if ($value instanceof \Stringable) {
3✔
50
            return (string)$value;
3✔
51
        }
52

53
        return null;
×
54
    }
55
}
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