• 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

91.67
/src/Assets/ScriptAsset.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Nette\Assets;
6

7
use Nette\Utils\Html;
8

9

10
/**
11
 * Script asset.
12
 */
13
class ScriptAsset 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 ?string $type = null,
20
                /** SRI integrity hash */
21
                public readonly ?string $integrity = null,
22
        ) {
23
        }
1✔
24

25

26
        public function __toString(): string
27
        {
28
                return $this->url;
×
29
        }
30

31

32
        public function getHtmlElement(): Html
33
        {
34
                return Html::el('script', array_filter([
1✔
35
                        'src' => $this->url,
1✔
36
                        'type' => $this->type,
1✔
37
                        'integrity' => $this->integrity,
1✔
38
                        'crossorigin' => $this->integrity ? 'anonymous' : null,
1✔
39
                ], fn($value) => $value !== null));
1✔
40
        }
41

42

43
        public function getHtmlPreloadElement(): Html
44
        {
45
                return Html::el('link', $this->type === 'module'
1✔
46
                        ? ['rel' => 'modulepreload', 'href' => $this->url]
1✔
47
                        : ['rel' => 'preload', 'href' => $this->url, 'as' => 'script']);
1✔
48
        }
49
}
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