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