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

Region   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 46
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __toString() 0 4 1
A setName() 0 9 2
A getName() 0 4 1
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