Passed
Push — master ( fb865f...3ad45c )
by Romain
51s queued 14s
created

Reaction::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
c 1
b 0
f 1
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Model\Callback;
6
7
class Reaction
8
{
9
    public const REACTION_SMILE = 'smile';
10
    public const REACTION_ANGRY = 'angry';
11
    public const REACTION_SAD = 'sad';
12
    public const REACTION_WOW = 'wow';
13
    public const REACTION_LOVE = 'love';
14
    public const REACTION_LIKE = 'like';
15
    public const REACTION_DISLIKE = 'dislike';
16
    public const REACTION_OTHER = 'other';
17
18
    public const ACTION_REACT = 'react';
19
    public const ACTION_UNREACT = 'unreact';
20
21
    protected $reaction;
22
    protected $emoji;
23
    protected $action;
24
    protected $mid;
25
26
    /**
27
     * Reaction constructor.
28
     */
29 1
    public function __construct(string $reaction, string $emoji, string $action, string $mid)
30
    {
31 1
        $this->reaction = $reaction;
32 1
        $this->emoji = $emoji;
33 1
        $this->action = $action;
34 1
        $this->mid = $mid;
35 1
    }
36
37
    public function getReaction(): string
38
    {
39
        return $this->reaction;
40
    }
41
42
    public function getEmoji(): string
43
    {
44
        return $this->emoji;
45
    }
46
47
    public function getAction(): string
48
    {
49
        return $this->action;
50
    }
51
52
    public function getMid(): string
53
    {
54
        return $this->mid;
55
    }
56
57
    /**
58
     * @return \Kerox\Messenger\Model\Callback\Reaction
59
     */
60 1
    public static function create(array $callbackData): self
61
    {
62 1
        return new self(
63 1
            $callbackData['reaction'],
64 1
            $callbackData['emoji'],
65 1
            $callbackData['action'],
66 1
            $callbackData['mid']
67
        );
68
    }
69
}
70