AdminLevel.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of the Geocoder package.
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. *
  8. * @license MIT License
  9. */
  10. namespace Geocoder\Model;
  11. /**
  12. * @author William Durand <william.durand1@gmail.com>
  13. */
  14. final class AdminLevel
  15. {
  16. /**
  17. * @var int
  18. */
  19. private $level;
  20. /**
  21. * @var string
  22. */
  23. private $name;
  24. /**
  25. * @var string|null
  26. */
  27. private $code;
  28. /**
  29. * @param int $level
  30. * @param string $name
  31. * @param string|null $code
  32. */
  33. public function __construct(int $level, string $name, string $code = null)
  34. {
  35. $this->level = $level;
  36. $this->name = $name;
  37. $this->code = $code;
  38. }
  39. /**
  40. * Returns the administrative level.
  41. *
  42. * @return int Level number [1,5]
  43. */
  44. public function getLevel(): int
  45. {
  46. return $this->level;
  47. }
  48. /**
  49. * Returns the administrative level name.
  50. *
  51. * @return string
  52. */
  53. public function getName(): string
  54. {
  55. return $this->name;
  56. }
  57. /**
  58. * Returns the administrative level short name.
  59. *
  60. * @return string|null
  61. */
  62. public function getCode()
  63. {
  64. return $this->code;
  65. }
  66. /**
  67. * Returns a string with the administrative level name.
  68. *
  69. * @return string
  70. */
  71. public function __toString(): string
  72. {
  73. return $this->getName();
  74. }
  75. }