-
-
Notifications
You must be signed in to change notification settings - Fork 154
Expand file tree
/
Copy pathByteOffsetRange.php
More file actions
45 lines (37 loc) · 898 Bytes
/
ByteOffsetRange.php
File metadata and controls
45 lines (37 loc) · 898 Bytes
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
<?php
namespace Phpactor\TextDocument;
class ByteOffsetRange
{
public function __construct(
private ByteOffset $start,
private ByteOffset $end
) {
}
public static function fromInts(int $start, int $end): self
{
return new self(
ByteOffset::fromInt($start),
ByteOffset::fromInt($end)
);
}
public static function fromByteOffset(ByteOffset $start): self
{
return new self($start, $start);
}
public static function fromByteOffsets(ByteOffset $start, ByteOffset $end): self
{
return new self($start, $end);
}
public function start(): ByteOffset
{
return $this->start;
}
public function length(): int
{
return $this->end->toInt() - $this->start->toInt();
}
public function end(): ByteOffset
{
return $this->end;
}
}