AuthorityInterface.php 3.0 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\MissingFeature;
  13. use League\Uri\Exceptions\SyntaxError;
  14. use Stringable;
  15. interface AuthorityInterface extends UriComponentInterface
  16. {
  17. /**
  18. * Returns the host component of the authority.
  19. */
  20. public function getHost(): ?string;
  21. /**
  22. * Returns the port component of the authority.
  23. */
  24. public function getPort(): ?int;
  25. /**
  26. * Returns the user information component of the authority.
  27. */
  28. public function getUserInfo(): ?string;
  29. /**
  30. * Returns an associative array containing all the Authority components.
  31. *
  32. * The returned a hashmap similar to PHP's parse_url return value
  33. *
  34. * @link https://tools.ietf.org/html/rfc3986
  35. *
  36. * @return array{user: ?string, pass : ?string, host: ?string, port: ?int}
  37. */
  38. public function components(): array;
  39. /**
  40. * Return an instance with the specified host.
  41. *
  42. * This method MUST retain the state of the current instance, and return
  43. * an instance that contains the specified host.
  44. *
  45. * A null value provided for the host is equivalent to removing the host
  46. * information.
  47. *
  48. * @throws SyntaxError for invalid component or transformations
  49. * that would result in an object in invalid state.
  50. * @throws MissingFeature for component or transformations
  51. * requiring IDN support when IDN support is not present
  52. * or misconfigured.
  53. */
  54. public function withHost(Stringable|string|null $host): self;
  55. /**
  56. * Return an instance with the specified port.
  57. *
  58. * This method MUST retain the state of the current instance, and return
  59. * an instance that contains the specified port.
  60. *
  61. * A null value provided for the port is equivalent to removing the port
  62. * information.
  63. *
  64. * @throws SyntaxError for invalid component or transformations
  65. * that would result in an object in invalid state.
  66. */
  67. public function withPort(?int $port): self;
  68. /**
  69. * Return an instance with the specified user information.
  70. *
  71. * This method MUST retain the state of the current instance, and return
  72. * an instance that contains the specified user information.
  73. *
  74. * Password is optional, but the user information MUST include the
  75. * user; a null value for the user is equivalent to removing user
  76. * information.
  77. *
  78. * @throws SyntaxError for invalid component or transformations
  79. * that would result in an object in invalid state.
  80. */
  81. public function withUserInfo(Stringable|string|null $user, Stringable|string|null $password = null): self;
  82. }