| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** |
| 6 | * This file is part of phpDocumentor. |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | * |
| 11 | * @link http://phpdoc.org |
| 12 | */ |
| 13 | |
| 14 | namespace phpDocumentor\Reflection; |
| 15 | |
| 16 | /** |
| 17 | * The location where an element occurs within a file. |
| 18 | * |
| 19 | * @psalm-immutable |
| 20 | */ |
| 21 | final class Location |
| 22 | { |
| 23 | /** @var int */ |
| 24 | private $lineNumber = 0; |
| 25 | |
| 26 | /** @var int */ |
| 27 | private $columnNumber = 0; |
| 28 | |
| 29 | /** |
| 30 | * Initializes the location for an element using its line number in the file and optionally the column number. |
| 31 | */ |
| 32 | public function __construct(int $lineNumber, int $columnNumber = 0) |
| 33 | { |
| 34 | $this->lineNumber = $lineNumber; |
| 35 | $this->columnNumber = $columnNumber; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Returns the line number that is covered by this location. |
| 40 | */ |
| 41 | public function getLineNumber() : int |
| 42 | { |
| 43 | return $this->lineNumber; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Returns the column number (character position on a line) for this location object. |
| 48 | */ |
| 49 | public function getColumnNumber() : int |
| 50 | { |
| 51 | return $this->columnNumber; |
| 52 | } |
| 53 | } |