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