DataPathInterface.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 SplFileObject;
  13. use Stringable;
  14. interface DataPathInterface extends PathInterface
  15. {
  16. /**
  17. * Retrieve the data mime type associated to the URI.
  18. *
  19. * If no mimetype is present, this method MUST return the default mimetype 'text/plain'.
  20. *
  21. * @see http://tools.ietf.org/html/rfc2397#section-2
  22. */
  23. public function getMimeType(): string;
  24. /**
  25. * Retrieve the parameters associated with the Mime Type of the URI.
  26. *
  27. * If no parameters is present, this method MUST return the default parameter 'charset=US-ASCII'.
  28. *
  29. * @see http://tools.ietf.org/html/rfc2397#section-2
  30. */
  31. public function getParameters(): string;
  32. /**
  33. * Retrieve the mediatype associated with the URI.
  34. *
  35. * If no mediatype is present, this method MUST return the default parameter 'text/plain;charset=US-ASCII'.
  36. *
  37. * @see http://tools.ietf.org/html/rfc2397#section-3
  38. *
  39. * @return string The URI scheme.
  40. */
  41. public function getMediaType(): string;
  42. /**
  43. * Retrieves the data string.
  44. *
  45. * Retrieves the data part of the path. If no data part is provided return
  46. * an empty string
  47. */
  48. public function getData(): string;
  49. /**
  50. * Tells whether the data is binary safe encoded.
  51. */
  52. public function isBinaryData(): bool;
  53. /**
  54. * Save the data to a specific file.
  55. */
  56. public function save(string $path, string $mode = 'w'): SplFileObject;
  57. /**
  58. * Returns an instance where the data part is base64 encoded.
  59. *
  60. * This method MUST retain the state of the current instance, and return
  61. * an instance where the data part is base64 encoded
  62. */
  63. public function toBinary(): self;
  64. /**
  65. * Returns an instance where the data part is url encoded following RFC3986 rules.
  66. *
  67. * This method MUST retain the state of the current instance, and return
  68. * an instance where the data part is url encoded
  69. */
  70. public function toAscii(): self;
  71. /**
  72. * Return an instance with the specified mediatype parameters.
  73. *
  74. * This method MUST retain the state of the current instance, and return
  75. * an instance that contains the specified mediatype parameters.
  76. *
  77. * Users must provide encoded characters.
  78. *
  79. * An empty parameters value is equivalent to removing the parameter.
  80. */
  81. public function withParameters(Stringable|string $parameters): self;
  82. }