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

Region   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 38
rs 10

3 Methods

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