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

nette / assets / 15179342226

22 May 2025 06:03AM UTC coverage: 95.436% (+0.4%) from 95.067%
15179342226

push

github

dg
DIExtension: parameters are passed by constructor (BC break)

6 of 6 new or added lines in 1 file covered. (100.0%)

15 existing lines in 5 files now uncovered.

460 of 482 relevant lines covered (95.44%)

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

26

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

32

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

43

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