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

nette / latte / 18955707548

30 Oct 2025 09:34PM UTC coverage: 93.854% (-0.08%) from 93.929%
18955707548

push

github

dg
Released version 3.0.24

5238 of 5581 relevant lines covered (93.85%)

0.94 hits per line

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

93.33
/src/Latte/PositionAwareException.php
1
<?php
2

3
/**
4
 * This file is part of the Latte (https://latte.nette.org)
5
 * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
 */
7

8
declare(strict_types=1);
9

10
namespace Latte;
11

12
use Latte\Compiler\Position;
13

14

15
/** @internal */
16
trait PositionAwareException
17
{
18
        public ?string $sourceCode = null;
19
        public ?string $sourceName = null;
20
        public ?Position $position = null;
21
        private string $origMessage;
22

23

24
        public function setSource(string $code, ?string $name = null): self
1✔
25
        {
26
                $this->sourceCode = $code;
1✔
27
                $this->sourceName = $name;
1✔
28
                $this->generateMessage();
1✔
29
                return $this;
1✔
30
        }
31

32

33
        private function generateMessage(): void
34
        {
35
                $this->origMessage ??= $this->message;
1✔
36
                $info = [];
1✔
37
                if ($this->sourceName && @is_file($this->sourceName)) { // @ - may trigger error
1✔
38
                        $info[] = "in '" . str_replace(dirname($this->sourceName, 2), '...', $this->sourceName) . "'";
×
39
                }
40
                if ($this->position) {
1✔
41
                        $info[] = $this->position;
1✔
42
                }
43
                $this->message = $info
1✔
44
                        ? rtrim($this->origMessage, '.') . ' (' . implode(' ', $info) . ')'
1✔
45
                        : $this->origMessage;
1✔
46
        }
1✔
47
}
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