Passed
Push — master ( 61fa52...b9d74d )
by Vladimir
13:13
created

Attachment   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 68.75%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 66
ccs 11
cts 16
cp 0.6875
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getType() 0 4 1
A getPath() 0 4 1
A possibleTypes() 0 9 1
A toArray() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Drivers\ReceivedMessage;
6
7
use FondBot\Contracts\Arrayable;
8
9
class Attachment implements Arrayable
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
    protected $type;
17
    protected $path;
18
    protected $contents;
19
    protected $guzzle;
20
21 8
    public function __construct(string $type, string $path)
22
    {
23 8
        $this->type = $type;
24 8
        $this->path = $path;
25 8
    }
26
27
    /**
28
     * Get attachment type.
29
     *
30
     * @return string
31
     */
32 8
    public function getType(): string
33
    {
34 8
        return $this->type;
35
    }
36
37
    /**
38
     * Get path to the attachment.
39
     *
40
     * @return string
41
     */
42
    public function getPath(): string
43
    {
44
        return $this->path;
45
    }
46
47
    /**
48
     * Get all types.
49
     *
50
     * @return array
51
     */
52 4
    public static function possibleTypes(): array
53
    {
54
        return [
55 4
            static::TYPE_FILE,
56 4
            static::TYPE_IMAGE,
57 4
            static::TYPE_AUDIO,
58 4
            static::TYPE_VIDEO,
59
        ];
60
    }
61
62
    /**
63
     * Get the instance as an array.
64
     *
65
     * @return array
66
     */
67
    public function toArray(): array
68
    {
69
        return [
70
            'type' => $this->type,
71
            'path' => $this->path,
72
        ];
73
    }
74
}
75