blob: 8028196c677b8c21c287f18268ad148ac323a34e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
<?php
namespace SourceSpan;
use League\Uri\Contracts\UriInterface;
/**
* The implementation of {@see SourceLocation} based on a {@see SourceFile}.
*
* @see SourceFile::location()
*/
final class FileLocation extends SourceLocationMixin
{
/**
* @internal
*/
public function __construct(
private readonly SourceFile $file,
private readonly int $offset,
) {
}
public function getFile(): SourceFile
{
return $this->file;
}
public function getOffset(): int
{
return $this->offset;
}
public function getLine(): int
{
return $this->file->getLine($this->offset);
}
public function getColumn(): int
{
return $this->file->getColumn($this->offset);
}
public function getSourceUrl(): ?UriInterface
{
return $this->file->getSourceUrl();
}
public function pointSpan(): FileSpan
{
return new ConcreteFileSpan($this->file, $this->offset, $this->offset);
}
}
|