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

Acl::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 Acl
7
 *
8
 * Acl is the AWS term for calculating the access of a file. This allows you to choose appropriate
9
 * permissions for a file by picking a possible acl.
10
 *
11
 * @package EddTurtle\DirectUpload
12
 */
13
class Acl
14
{
15
16
    private $possibleOptions = [
17
        "authenticated-read",
18
        "aws-exec-read",
19
        "bucket-owner-full-control",
20
        "bucket-owner-read",
21
        "log-delivery-write",
22
        "private",
23
        "public-read",
24
        "public-read-write",
25
    ];
26
27
    private $name;
28
29
    public function __construct($acl)
30
    {
31
        $this->setName($acl);
32
    }
33
34
    public function __toString()
35
    {
36
        return $this->getName();
37
    }
38
39
    public function setName($acl)
40
    {
41
        $acl = strtolower($acl);
42
        if (in_array($acl, $this->possibleOptions)) {
43
            $this->name = $acl;
44
        } else {
45
            throw new InvalidAclException;
46
        }
47
    }
48
49
    public function getName()
50
    {
51
        return $this->name;
52
    }
53
54
}