• 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

92.86
/src/Assets/StyleAsset.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Nette\Assets;
6

7
use Nette\Utils\Html;
8

9

10
/**
11
 * Style asset.
12
 */
13
class StyleAsset 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
                /** Media query for the stylesheet */
20
                public readonly ?string $media = null,
21
                /** SRI integrity hash */
22
                public readonly ?string $integrity = null,
23
        ) {
24
        }
1✔
25

26

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

32

33
        public function getHtmlElement(): Html
34
        {
35
                return Html::el('link', array_filter([
1✔
36
                        'rel' => 'stylesheet',
1✔
37
                        'href' => $this->url,
1✔
38
                        'media' => $this->media,
1✔
39
                        'integrity' => $this->integrity,
1✔
40
                        'crossorigin' => $this->integrity ? 'anonymous' : null,
1✔
41
                ], fn($value) => $value !== null));
1✔
42
        }
43

44

45
        public function getHtmlPreloadElement(): Html
46
        {
47
                return Html::el('link', [
1✔
48
                        'rel' => 'preload',
1✔
49
                        'href' => $this->url,
1✔
50
                        'as' => 'style',
1✔
51
                ]);
52
        }
53
}
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