Completed
Pull Request — master (#2)
by
unknown
02:39
created

Region::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace DirectUpload;
4
5
class Region
6
{
7
8
    private $possibleOptions = [
9
        "us-east-1",
10
        "us-west-2",
11
        "us-west-1",
12
        "eu-west-1",
13
        "eu-central-1",
14
        "ap-southeast-1",
15
        "ap-northeast-1",
16
        "ap-southeast-2",
17
        "ap-northeast-2",
18
        "sa-east-1"
19
    ];
20
21
    private $name;
22
23
    public function __construct($region)
24
    {
25
        $this->setName($region);
26
    }
27
28
    public function setName($region)
29
    {
30
        if (in_array($region, $this->possibleOptions)) {
31
            $this->name = $region;
32
        } else {
33
            throw new InvalidRegionException;
34
        }
35
    }
36
37
    public function getName()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
38
    {
39
        return $this->name;
40
    }
41
42
}