UriInfo.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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;
  12. use Deprecated;
  13. use League\Uri\Contracts\UriInterface;
  14. use Psr\Http\Message\UriInterface as Psr7UriInterface;
  15. /**
  16. * @deprecated since version 7.0.0
  17. * @codeCoverageIgnore
  18. * @see BaseUri
  19. */
  20. final class UriInfo
  21. {
  22. /**
  23. * @codeCoverageIgnore
  24. */
  25. private function __construct()
  26. {
  27. }
  28. /**
  29. * Tells whether the URI represents an absolute URI.
  30. */
  31. #[Deprecated(message:'use League\Uri\BaseUri::isAbsolute() instead', since:'league/uri:7.0.0')]
  32. public static function isAbsolute(Psr7UriInterface|UriInterface $uri): bool
  33. {
  34. return BaseUri::from($uri)->isAbsolute();
  35. }
  36. /**
  37. * Tell whether the URI represents a network path.
  38. */
  39. #[Deprecated(message:'use League\Uri\BaseUri::isNetworkPath() instead', since:'league/uri:7.0.0')]
  40. public static function isNetworkPath(Psr7UriInterface|UriInterface $uri): bool
  41. {
  42. return BaseUri::from($uri)->isNetworkPath();
  43. }
  44. /**
  45. * Tells whether the URI represents an absolute path.
  46. */
  47. #[Deprecated(message:'use League\Uri\BaseUri::isAbsolutePath() instead', since:'league/uri:7.0.0')]
  48. public static function isAbsolutePath(Psr7UriInterface|UriInterface $uri): bool
  49. {
  50. return BaseUri::from($uri)->isAbsolutePath();
  51. }
  52. /**
  53. * Tell whether the URI represents a relative path.
  54. *
  55. */
  56. #[Deprecated(message:'use League\Uri\BaseUri::isRelativePath() instead', since:'league/uri:7.0.0')]
  57. public static function isRelativePath(Psr7UriInterface|UriInterface $uri): bool
  58. {
  59. return BaseUri::from($uri)->isRelativePath();
  60. }
  61. /**
  62. * Tells whether both URI refers to the same document.
  63. */
  64. #[Deprecated(message:'use League\Uri\BaseUri::isSameDocument() instead', since:'league/uri:7.0.0')]
  65. public static function isSameDocument(Psr7UriInterface|UriInterface $uri, Psr7UriInterface|UriInterface $baseUri): bool
  66. {
  67. return BaseUri::from($baseUri)->isSameDocument($uri);
  68. }
  69. /**
  70. * Returns the URI origin property as defined by WHATWG URL living standard.
  71. *
  72. * {@see https://url.spec.whatwg.org/#origin}
  73. *
  74. * For URI without a special scheme the method returns null
  75. * For URI with the file scheme the method will return null (as this is left to the implementation decision)
  76. * For URI with a special scheme the method returns the scheme followed by its authority (without the userinfo part)
  77. */
  78. #[Deprecated(message:'use League\Uri\BaseUri::origin() instead', since:'league/uri:7.0.0')]
  79. public static function getOrigin(Psr7UriInterface|UriInterface $uri): ?string
  80. {
  81. return BaseUri::from($uri)->origin()?->__toString();
  82. }
  83. /**
  84. * Tells whether two URI do not share the same origin.
  85. *
  86. * @see UriInfo::getOrigin()
  87. */
  88. #[Deprecated(message:'use League\Uri\BaseUri::isCrossOrigin() instead', since:'league/uri:7.0.0')]
  89. public static function isCrossOrigin(Psr7UriInterface|UriInterface $uri, Psr7UriInterface|UriInterface $baseUri): bool
  90. {
  91. return BaseUri::from($baseUri)->isCrossOrigin($uri);
  92. }
  93. }