Location.php 1.3 KB

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