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

Acl   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 42
rs 10
c 0
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 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
}