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

nette / assets / 15480186418

06 Jun 2025 12:39AM UTC coverage: 91.984% (+0.03%) from 91.952%
15480186418

push

github

dg
added php.ini

459 of 499 relevant lines covered (91.98%)

0.92 hits per line

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

94.12
/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 $file = null,
18
                public readonly ?string $type = null,
19
                /** SRI integrity hash */
20
                public readonly ?string $integrity = null,
21
                public readonly string|bool|null $crossorigin = null,
22
        ) {
23
        }
1✔
24

25

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

31

32
        public function getImportElement(): 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->crossorigin ?? (bool) $this->integrity,
1✔
39
                ], fn($value) => $value !== null));
1✔
40
        }
41

42

43
        public function getPreloadElement(): Html
44
        {
45
                return Html::el('link', array_filter($this->type === 'module'
1✔
46
                        ? [
47
                                'rel' => 'modulepreload',
1✔
48
                                'href' => $this->url,
1✔
49
                                'crossorigin' => $this->crossorigin,
1✔
50
                        ]
51
                        : [
52
                                'rel' => 'preload',
1✔
53
                                'href' => $this->url,
1✔
54
                                'as' => 'script',
1✔
55
                                'crossorigin' => $this->crossorigin,
1✔
56
                        ]));
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