Completed
Push — master ( a128d4...ff765d )
by Vladimir
10:36
created

Attachment   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
dl 0
loc 69
ccs 18
cts 27
cp 0.6667
rs 10
c 0
b 0
f 0
wmc 9
lcom 0
cbo 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getType() 0 4 1
A create() 0 4 1
A setType() 0 6 1
A getPath() 0 4 1
A setPath() 0 6 1
A getParameters() 0 4 1
A setParameters() 0 6 1
A possibleTypes() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Templates;
6
7
use Illuminate\Support\Collection;
8
9
class Attachment
10
{
11
    public const TYPE_FILE = 'file';
12
    public const TYPE_IMAGE = 'image';
13
    public const TYPE_AUDIO = 'audio';
14
    public const TYPE_VIDEO = 'video';
15
16
    private $type;
17
    private $path;
18
    private $parameters;
19
20 13
    public function __construct(string $type, string $path, array $parameters = [])
21
    {
22 13
        $this->type = $type;
23 13
        $this->path = $path;
24 13
        $this->parameters = collect($parameters);
25 13
    }
26
27 13
    public static function create(string $type, string $path, array $parameters = [])
28
    {
29 13
        return new static($type, $path, $parameters);
30
    }
31
32 12
    public function getType(): string
33
    {
34 12
        return $this->type;
35
    }
36
37
    public function setType(string $type): Attachment
38
    {
39
        $this->type = $type;
40
41
        return $this;
42
    }
43
44 4
    public function getPath(): string
45
    {
46 4
        return $this->path;
47
    }
48
49
    public function setPath(string $path): Attachment
50
    {
51
        $this->path = $path;
52
53
        return $this;
54
    }
55
56 4
    public function getParameters(): Collection
57
    {
58 4
        return $this->parameters;
59
    }
60
61
    public function setParameters(array $parameters): Attachment
62
    {
63
        $this->parameters = collect($parameters);
64
65
        return $this;
66
    }
67
68 5
    public static function possibleTypes(): array
69
    {
70
        return [
71 5
            static::TYPE_FILE,
72 5
            static::TYPE_IMAGE,
73 5
            static::TYPE_AUDIO,
74 5
            static::TYPE_VIDEO,
75
        ];
76
    }
77
}
78