Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 7 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| LocationRange | |
0.00% |
0 / 7 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| __toString | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| jsonSerialize | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | declare( strict_types = 1 ); |
| 3 | |
| 4 | namespace Wikimedia\WikiPEG; |
| 5 | |
| 6 | class LocationRange implements \JsonSerializable { |
| 7 | /** @var Location */ |
| 8 | public $start; |
| 9 | |
| 10 | /** @var Location */ |
| 11 | public $end; |
| 12 | |
| 13 | /** |
| 14 | * @param int $startOffset |
| 15 | * @param int $startLine |
| 16 | * @param int $startColumn |
| 17 | * @param int $endOffset |
| 18 | * @param int $endLine |
| 19 | * @param int $endColumn |
| 20 | */ |
| 21 | public function __construct( $startOffset, $startLine, $startColumn, $endOffset, $endLine, $endColumn ) { |
| 22 | $this->start = new Location( $startOffset, $startLine, $startColumn ); |
| 23 | $this->end = new Location( $endOffset, $endLine, $endColumn ); |
| 24 | } |
| 25 | |
| 26 | /** @return string */ |
| 27 | public function __toString() { |
| 28 | return "{$this->start}-{$this->end}"; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Emit a JSON serialization similar to JS, for testing |
| 33 | * @return array |
| 34 | */ |
| 35 | #[\ReturnTypeWillChange] |
| 36 | public function jsonSerialize(): array { |
| 37 | return [ |
| 38 | 'start' => $this->start, |
| 39 | 'end' => $this->end, |
| 40 | ]; |
| 41 | } |
| 42 | } |