Completed
Pull Request — master (#3)
by Romain
01:42
created

Entry   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 70
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getId() 0 4 1
A getTime() 0 4 1
A getEvents() 0 4 1
A create() 0 9 2
1
<?php
2
namespace Kerox\Messenger\Model\Callback;
3
4
use Kerox\Messenger\Callback\CallbackEventFactory;
5
6
class Entry
7
{
8
9
    /**
10
     * @var string
11
     */
12
    protected $id;
13
14
    /**
15
     * @var int
16
     */
17
    protected $time;
18
19
    /**
20
     * @var array
21
     */
22
    protected $events;
23
24
    /**
25
     * Entry constructor.
26
     *
27
     * @param string $id
28
     * @param int $time
29
     * @param array $events
30
     */
31
    public function __construct(string $id, int $time, array $events)
32
    {
33
        $this->id = $id;
34
        $this->time = $time;
35
        $this->events = $events;
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getId(): string
42
    {
43
        return $this->id;
44
    }
45
46
    /**
47
     * @return int
48
     */
49
    public function getTime(): int
50
    {
51
        return $this->time;
52
    }
53
54
    /**
55
     * @return array
56
     */
57
    public function getEvents(): array
58
    {
59
        return $this->events;
60
    }
61
62
    /**
63
     * @param array $entry
64
     * @return static
65
     */
66
    public static function create(array $entry)
67
    {
68
        $events = [];
69
        foreach ($entry['messaging'] as $event) {
70
            $events[] = CallbackEventFactory::create($event);
71
        }
72
73
        return new static($entry['id'], $entry['time'], $events);
74
    }
75
}
76