Completed
Push — master ( 17cc82...f31b80 )
by Vladimir
02:38
created

Attachment::getPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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 12
    public function __construct(string $type, string $path)
22
    {
23 12
        $this->type = $type;
24 12
        $this->path = $path;
25 12
    }
26
27
    /**
28
     * Get attachment type.
29
     *
30
     * @return string
31
     */
32 12
    public function getType(): string
33
    {
34 12
        return $this->type;
35
    }
36
37
    /**
38
     * Get path to the attachment.
39
     *
40
     * @return string
41
     */
42 4
    public function getPath(): string
43
    {
44 4
        return $this->path;
45
    }
46
47
    /**
48
     * Get all types.
49
     *
50
     * @return array
51
     */
52 5
    public static function possibleTypes(): array
53
    {
54
        return [
55 5
            static::TYPE_FILE,
56 5
            static::TYPE_IMAGE,
57 5
            static::TYPE_AUDIO,
58 5
            static::TYPE_VIDEO,
59
        ];
60
    }
61
62
    /**
63
     * Get the instance as an array.
64
     *
65
     * @return array
66
     */
67 4
    public function toArray(): array
68
    {
69
        return [
70 4
            'type' => $this->type,
71 4
            'path' => $this->path,
72
        ];
73
    }
74
}
75