PluginProbe
Media Cloud Sync / 1.3.11
Media Cloud Sync v1.3.11
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
media-cloud-sync / includes / sdk / s3 / GuzzleHttp / Psr7 / UriComparator.php

UriComparator.php in Media Cloud Sync 1.3.11, at includes/sdk/s3/GuzzleHttp/Psr7/UriComparator.php

44 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace Dudlewebs\WPMCS\s3\GuzzleHttp\Psr7;
5
6 use Dudlewebs\WPMCS\s3\Psr\Http\Message\UriInterface;
7 /**
8 * Provides methods to determine if a modified URL should be considered cross-origin.
9 *
10 * @author Graham Campbell
11 */
12 final class UriComparator
13 {
14 /**
15 * Determines if a modified URL should be considered cross-origin with
16 * respect to an original URL.
17 */
18 public static function isCrossOrigin(UriInterface $original, UriInterface $modified) : bool
19 {
20 if (\strcasecmp($original->getHost(), $modified->getHost()) !== 0) {
21 return \true;
22 }
23 if ($original->getScheme() !== $modified->getScheme()) {
24 return \true;
25 }
26 if (self::computePort($original) !== self::computePort($modified)) {
27 return \true;
28 }
29 return \false;
30 }
31 private static function computePort(UriInterface $uri) : int
32 {
33 $port = $uri->getPort();
34 if (null !== $port) {
35 return $port;
36 }
37 return 'https' === $uri->getScheme() ? 443 : 80;
38 }
39 private function __construct()
40 {
41 // cannot be instantiated
42 }
43 }
44