UriComponentInterface.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 JsonSerializable;
  13. use Stringable;
  14. /**
  15. * @method static when(callable|bool $condition, callable $onSuccess, ?callable $onFail = null) conditionally return a new instance
  16. * @method bool equals(mixed $value) tells whether the submitted value is equal to the current instance value
  17. */
  18. interface UriComponentInterface extends JsonSerializable, Stringable
  19. {
  20. /**
  21. * Returns the instance string representation.
  22. *
  23. * If the instance is defined, the value returned MUST be percent-encoded,
  24. * but MUST NOT double-encode any characters. To determine what characters
  25. * to encode, please refer to RFC 3986, Sections 2 and 3.
  26. *
  27. * If the instance is not defined null is returned
  28. */
  29. public function value(): ?string;
  30. /**
  31. * Returns the instance string representation.
  32. *
  33. * If the instance is defined, the value returned MUST be percent-encoded,
  34. * but MUST NOT double-encode any characters. To determine what characters
  35. * to encode, please refer to RFC 3986, Sections 2 and 3.
  36. *
  37. * If the instance is not defined, an empty string is returned
  38. */
  39. public function toString(): string;
  40. /**
  41. * Returns the instance string representation.
  42. *
  43. * If the instance is defined, the value returned MUST be percent-encoded,
  44. * but MUST NOT double-encode any characters. To determine what characters
  45. * to encode, please refer to RFC 3986, Sections 2 and 3.
  46. *
  47. * If the instance is not defined, an empty string is returned
  48. */
  49. public function __toString(): string;
  50. /**
  51. * Returns the instance json representation.
  52. *
  53. * If the instance is defined, the value returned MUST be percent-encoded,
  54. * but MUST NOT double-encode any characters. To determine what characters
  55. * to encode, please refer to RFC 3986 or RFC 1738.
  56. *
  57. * If the instance is not defined, null is returned
  58. */
  59. public function jsonSerialize(): ?string;
  60. /**
  61. * Returns the instance string representation with its optional URI delimiters.
  62. *
  63. * The value returned MUST be percent-encoded, but MUST NOT double-encode any
  64. * characters. To determine what characters to encode, please refer to RFC 3986,
  65. * Sections 2 and 3.
  66. *
  67. * If the instance is not defined, an empty string is returned
  68. */
  69. public function getUriComponent(): string;
  70. }