Completed
Branch develop (a0a623)
by Romain
02:33
created

Attachment   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A jsonSerialize() 0 8 1
1
<?php
2
namespace Kerox\Messenger\Message;
3
4
use Kerox\Messenger\ValidatorTrait;
5
6
class Attachment implements \JsonSerializable
7
{
8
9
    use ValidatorTrait;
10
11
    const TYPE_IMAGE = 'image';
12
    const TYPE_AUDIO = 'audio';
13
    const TYPE_VIDEO = 'video';
14
    const TYPE_FILE = 'file';
15
    const TYPE_TEMPLATE = 'template';
16
17
    /**
18
     * @var string
19
     */
20
    protected $type;
21
22
    /**
23
     * Attachment constructor.
24
     *
25
     * @param string $type
26
     */
27
    public function __construct(string $type)
28
    {
29
        $this->type = $type;
30
    }
31
32
    /**
33
     * @return array
34
     */
35
    public function jsonSerialize(): array
36
    {
37
        $json = [
38
            'type' => $this->type,
39
        ];
40
41
        return $json;
42
    }
43
}