UserInfoInterface.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 Stringable;
  13. interface UserInfoInterface extends UriComponentInterface
  14. {
  15. /**
  16. * Returns the user component part.
  17. */
  18. public function getUser(): ?string;
  19. /**
  20. * Returns the pass component part.
  21. */
  22. public function getPass(): ?string;
  23. /**
  24. * Returns an associative array containing all the User Info components.
  25. *
  26. * The returned a hashmap similar to PHP's parse_url return value
  27. *
  28. * @link https://tools.ietf.org/html/rfc3986
  29. *
  30. * @return array{user: ?string, pass : ?string}
  31. */
  32. public function components(): array;
  33. /**
  34. * Returns an instance with the specified user and/or pass.
  35. *
  36. * This method MUST retain the state of the current instance, and return
  37. * an instance that contains the specified new username
  38. * otherwise it returns the same instance unchanged.
  39. *
  40. * A variable equal to null is equivalent to removing the complete user information.
  41. */
  42. public function withUser(Stringable|string|null $username): self;
  43. /**
  44. * Returns an instance with the specified user and/or pass.
  45. *
  46. * This method MUST retain the state of the current instance, and return
  47. * an instance that contains the specified password if the user is specified
  48. * otherwise it returns the same instance unchanged.
  49. *
  50. * An empty user is equivalent to removing the user information.
  51. */
  52. public function withPass(Stringable|string|null $password): self;
  53. }