Completed
Push — master ( 8c79df...2723f8 )
by Edd
02:08
created

Region::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace EddTurtle\DirectUpload;
4
5
/**
6
 * Class Region
7
 *
8
 * Region signifies an AWS Region, created and identified by it's hyphenated name.
9
 * More info on these can be found at: http://amzn.to/1FtPG6r
10
 *
11
 * @package EddTurtle\DirectUpload
12
 */
13
class Region
14
{
15
16
    private $possibleOptions = [
17
        "ap-northeast-1",
18
        "ap-northeast-2",
19
        "ap-south-1",
20
        "ap-southeast-1",
21
        "ap-southeast-2",
22
        "eu-central-1",
23
        "eu-west-1",
24
        "sa-east-1",
25
        "us-east-1",
26
        "us-east-2",
27
        "us-west-1",
28
        "us-west-2",
29
    ];
30
31
    private $name;
32
33
    public function __construct($region)
34
    {
35
        $this->setName($region);
36
    }
37
38
    public function __toString()
39
    {
40
        return $this->getName();
41
    }
42
43
    public function setName($region)
44
    {
45
        $region = strtolower($region);
46
        if (in_array($region, $this->possibleOptions)) {
47
            $this->name = $region;
48
        } else {
49
            throw new InvalidRegionException;
50
        }
51
    }
52
53
    public function getName()
54
    {
55
        return $this->name;
56
    }
57
58
}
59