Completed
Push — development ( 4cbc56...9c238f )
by Thomas
27s
created

LogEntity   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A toDatabaseArray() 0 9 1
A fromDatabaseArray() 0 9 1
A setData() 0 10 3
A toArray() 0 4 1
1
<?php
2
3
namespace Oc\Postfix;
4
5
class LogEntity
6
{
7
    /**
8
     * @var int
9
     */
10
    public $id;
11
12
    /**
13
     * @var \DateTimeInterface
14
     */
15
    public $created;
16
17
    /**
18
     * @var string
19
     */
20
    public $status;
21
22
    /**
23
     * @var string
24
     */
25
    public $email;
26
27
    /**
28
     * @return array
29
     */
30
    public function toDatabaseArray()
31
    {
32
        return [
33
            'id' => (int) $this->id,
34
            'email' => $this->email,
35
            'status' => $this->status,
36
            'created' => $this->created,
37
        ];
38
    }
39
40
    /**
41
     * @param array $data
42
     * @return $this
43
     */
44
    public function fromDatabaseArray(array $data)
45
    {
46
        $this->id = (int) $data['id'];
47
        $this->email = $data['email'];
48
        $this->status = $data['status'];
49
        $this->created = $data['created'];
50
51
        return $this;
52
    }
53
54
    /**
55
     * @param array $data
56
     */
57
    public function setData(array $data)
58
    {
59
        foreach ($data as $key => $value) {
60
            if (!property_exists($this, $key)) {
61
                continue;
62
            }
63
64
            $this->{$key} = $value;
65
        }
66
    }
67
68
    /**
69
     * @return array
70
     */
71
    public function toArray()
72
    {
73
        return get_object_vars($this);
74
    }
75
}
76