Completed
Push — master ( 7671f5...371846 )
by Romain
32s queued 12s
created

AbstractAttachment   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

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