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

nette / assets / 15009594433

14 May 2025 12:38AM UTC coverage: 95.411% (+2.0%) from 93.401%
15009594433

push

github

dg
readme: added info about custom mappers

395 of 414 relevant lines covered (95.41%)

0.95 hits per line

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

94.12
/src/Assets/VideoAsset.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Nette\Assets;
6

7
use Nette\Utils\Html;
8

9

10
/**
11
 * Video asset.
12
 */
13
class VideoAsset implements Asset, HtmlRenderable
14
{
15
        public function __construct(
1✔
16
                public readonly string $url,
17
                public readonly ?string $mimeType = null,
18
                public readonly ?string $sourcePath = null,
19
                public readonly ?int $width = null,
20
                public readonly ?int $height = null,
21
                /** Duration in seconds */
22
                public readonly ?float $duration = null,
23
                /** Poster image URL */
24
                public readonly ?string $poster = null,
25
                public readonly bool $autoPlay = false,
26
        ) {
27
        }
1✔
28

29

30
        public function __toString(): string
31
        {
32
                return $this->url;
×
33
        }
34

35

36
        public function getHtmlElement(): Html
37
        {
38
                return Html::el('video', array_filter([
1✔
39
                        'src' => $this->url,
1✔
40
                        'width' => $this->width ? (string) $this->width : null,
1✔
41
                        'height' => $this->height ? (string) $this->height : null,
1✔
42
                        'type' => $this->mimeType,
1✔
43
                        'poster' => $this->poster,
1✔
44
                        'autoplay' => $this->autoPlay ? true : null,
1✔
45
                ], fn($value) => $value !== null));
1✔
46
        }
47

48

49
        public function getHtmlPreloadElement(): Html
50
        {
51
                return Html::el('link', array_filter([
1✔
52
                        'rel' => 'preload',
1✔
53
                        'href' => $this->url,
1✔
54
                        'as' => 'video',
1✔
55
                        'type' => $this->mimeType,
1✔
56
                ], fn($value) => $value !== null));
1✔
57
        }
58
}
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