Debian Codegraph @

vendor/mck89/peast/lib/Peast/Syntax/Position.php

raw
1 <?php
2 /**
3 * This file is part of the Peast package
4 *
5 * (c) Marco Marchiò <[email protected]>
6 *
7 * For the full copyright and license information refer to the LICENSE file
8 * distributed with this source code
9 */
10 namespace Peast\Syntax;
11
12 /**
13 * This class represents the position in the source code.
14 *
15 * @author Marco Marchiò <[email protected]>
16 */
17 class Position implements \JSONSerializable
18 {
19 /**
20 * Source line
21 *
22 * @var int
23 */
24 protected $line;
25
26 /**
27 * Source column
28 *
29 * @var int
30 */
31 protected $column;
32
33 /**
34 * Source index
35 *
36 * @var int
37 */
38 protected $index;
39
40 /**
41 * Class constructor
42 *
43 * @param int $line Source line
44 * @param int $column Source column
45 * @param int $index Source index
46 */
47 function __construct($line, $column, $index)
48 {
49 $this->line = $line;
50 $this->column = $column;
51 $this->index = $index;
52 }
53
54 /**
55 * Returns the source line
56 *
57 * @return int
58 */
59 public function getLine()
60 {
61 return $this->line;
62 }
63
64 /**
65 * Returns the source column
66 *
67 * @return int
68 */
69 public function getColumn()
70 {
71 return $this->column;
72 }
73
74 /**
75 * Returns the source index
76 *
77 * @return int
78 */
79 public function getIndex()
80 {
81 return $this->index;
82 }
83
84 /**
85 * Returns a serializable version of the object
86 *
87 * @return array
88 */
89 #[\ReturnTypeWillChange]
90 public function jsonSerialize()
91 {
92 return array(
93 "line" => $this->getLine(),
94 "column" => $this->getColumn(),
95 "index" => $this->getIndex()
96 );
97 }
98 }