• 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

94.12
/Classes/ViewHelpers/Media/SpotifyViewHelper.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\Traits\TagViewHelperCompatibility;
12
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
13

14
/**
15
 * Renders HTML code to embed a Spotify play button.
16
 */
17
class SpotifyViewHelper extends AbstractTagBasedViewHelper
18
{
19
    use TagViewHelperCompatibility;
20

21
    /**
22
     * Play button base url
23
     */
24
    private const string SPOTIFY_BASEURL = 'https://embed.spotify.com/';
25

26
    /**
27
     * @var string
28
     */
29
    protected $tagName = 'iframe';
30

31
    public function initializeArguments(): void
32
    {
33
        parent::initializeArguments();
3✔
34
        $this->registerUniversalTagAttributes();
3✔
35
        $this->registerArgument(
3✔
36
            'spotifyUri',
3✔
37
            'string',
3✔
38
            'Spotify URI to create the play button for. Right click any song, album or playlist in Spotify and ' .
3✔
39
            'select Copy Spotify URI.',
3✔
40
            true
3✔
41
        );
3✔
42
        $this->registerArgument('width', 'int', 'Width of the play button in pixels. Defaults to 300', false, 300);
3✔
43
        $this->registerArgument('height', 'int', 'Height of the play button in pixels. Defaults to 380', false, 380);
3✔
44
        $this->registerArgument(
3✔
45
            'compact',
3✔
46
            'boolean',
3✔
47
            'Whether to render the compact button with a fixed height of 80px.',
3✔
48
            false,
3✔
49
            false
3✔
50
        );
3✔
51
        $this->registerArgument(
3✔
52
            'theme',
3✔
53
            'string',
3✔
54
            'Theme to use. Can be "black" or "white" and is not available in compact mode. Defaults to "black".',
3✔
55
            false,
3✔
56
            'black'
3✔
57
        );
3✔
58
        $this->registerArgument(
3✔
59
            'view',
3✔
60
            'string',
3✔
61
            'View to use. Can be "list" or "coverart" and is not available in compact mode. Defaults to "list".',
3✔
62
            false,
3✔
63
            'list'
3✔
64
        );
3✔
65
    }
66

67
    public function render(): string
68
    {
69
        $spotifyUri = $this->arguments['spotifyUri'];
3✔
70
        /** @var int $width */
71
        $width = $this->arguments['width'];
3✔
72
        /** @var int $height */
73
        $height = $this->arguments['height'];
3✔
74
        /** @var string $theme */
75
        $theme = $this->arguments['theme'];
3✔
76
        /** @var string $view */
77
        $view = $this->arguments['view'];
3✔
78

79
        if (!in_array($theme, ['black', 'white'])) {
3✔
80
            $theme = 'black';
×
81
        }
82

83
        if (!in_array($view, ['coverart', 'list'])) {
3✔
84
            $view = 'list';
×
85
        }
86

87
        if ($this->arguments['compact']) {
3✔
88
            $height = 80;
×
89
        }
90

91
        $src = self::SPOTIFY_BASEURL . '?uri=' . $spotifyUri . '&theme=' . $theme . '&view=' . $view;
3✔
92

93
        $this->tag->forceClosingTag(true);
3✔
94
        $this->tag->addAttribute('src', $src);
3✔
95
        $this->tag->addAttribute('width', (string) $width);
3✔
96
        $this->tag->addAttribute('height', (string) $height);
3✔
97
        $this->tag->addAttribute('allowtransparancy', 'true');
3✔
98
        $this->tag->addAttribute('frameborder', '0');
3✔
99

100
        return $this->tag->render();
3✔
101
    }
102
}
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