-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathRegion.php
43 lines (36 loc) · 1.18 KB
/
Region.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
namespace Bunny\Storage;
class Region
{
public const FALKENSTEIN = 'de';
public const LONDON = 'uk';
public const STOCKHOLM = 'se';
public const NEW_YORK = 'ny';
public const LOS_ANGELES = 'la';
public const SINGAPORE = 'sg';
public const SYDNEY = 'syd';
public const SAO_PAULO = 'br';
public const JOHANNESBURG = 'jh';
public const LIST = [
self::FALKENSTEIN => 'Europe (Falkenstein)',
self::LONDON => 'Europe (London)',
self::STOCKHOLM => 'Europe (Stockholm)',
self::NEW_YORK => 'US East (New York)',
self::LOS_ANGELES => 'US West (Los Angeles)',
self::SINGAPORE => 'Asia (Singapore)',
self::SYDNEY => 'Oceania (Sydney)',
self::SAO_PAULO => 'LATAM (Sao Paulo)',
self::JOHANNESBURG => 'Africa (Johannesburg)',
];
public static function getBaseUrl(string $region): string
{
if (!isset(Region::LIST[$region])) {
throw new InvalidRegionException();
}
if ('de' === $region) {
return 'https://storage.bunnycdn.com/';
}
return sprintf('https://%s.storage.bunnycdn.com/', $region);
}
}