PathInterface.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * League.Uri (https://uri.thephpleague.com)
  4. *
  5. * (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. declare(strict_types=1);
  11. namespace League\Uri\Contracts;
  12. use League\Uri\Exceptions\SyntaxError;
  13. /**
  14. * @method static normalize() returns the normalized string representation of the component
  15. */
  16. interface PathInterface extends UriComponentInterface
  17. {
  18. /**
  19. * Returns the decoded path.
  20. */
  21. public function decoded(): string;
  22. /**
  23. * Tells whether the path is absolute or relative.
  24. */
  25. public function isAbsolute(): bool;
  26. /**
  27. * Tells whether the path has a trailing slash.
  28. */
  29. public function hasTrailingSlash(): bool;
  30. /**
  31. * Returns an instance without dot segments.
  32. *
  33. * This method MUST retain the state of the current instance, and return
  34. * an instance that contains the path component normalized by removing
  35. * the dot segment.
  36. *
  37. * @throws SyntaxError for invalid component or transformations
  38. * that would result in a object in invalid state.
  39. */
  40. public function withoutDotSegments(): self;
  41. /**
  42. * Returns an instance with a leading slash.
  43. *
  44. * This method MUST retain the state of the current instance, and return
  45. * an instance that contains the path component with a leading slash
  46. *
  47. * @throws SyntaxError for invalid component or transformations
  48. * that would result in a object in invalid state.
  49. */
  50. public function withLeadingSlash(): self;
  51. /**
  52. * Returns an instance without a leading slash.
  53. *
  54. * This method MUST retain the state of the current instance, and return
  55. * an instance that contains the path component without a leading slash
  56. *
  57. * @throws SyntaxError for invalid component or transformations
  58. * that would result in a object in invalid state.
  59. */
  60. public function withoutLeadingSlash(): self;
  61. /**
  62. * Returns an instance with a trailing slash.
  63. *
  64. * This method MUST retain the state of the current instance, and return
  65. * an instance that contains the path component with a trailing slash
  66. *
  67. * @throws SyntaxError for invalid component or transformations
  68. * that would result in a object in invalid state.
  69. */
  70. public function withTrailingSlash(): self;
  71. /**
  72. * Returns an instance without a trailing slash.
  73. *
  74. * This method MUST retain the state of the current instance, and return
  75. * an instance that contains the path component without a trailing slash
  76. *
  77. * @throws SyntaxError for invalid component or transformations
  78. * that would result in a object in invalid state.
  79. */
  80. public function withoutTrailingSlash(): self;
  81. }