Completed
Push — master ( ac056e...2fe264 )
by David
04:27 queued 01:15
created

Route   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 56.52%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 59
ccs 13
cts 23
cp 0.5652
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 12 2
A __construct() 0 3 1
A getId() 0 4 1
A getActions() 0 4 1
A getDescription() 0 4 1
A getFilter() 0 4 1
A getPriority() 0 4 1
A getCreatedAt() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (C) 2013 Mailgun
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license. See the LICENSE file for details.
10
 */
11
12
namespace Mailgun\Model\Route;
13
14
/**
15
 * @author David Garcia <[email protected]>
16
 */
17
final class Route
18
{
19
    private $id;
20
    private $priority;
21
    private $filter;
22
    private $actions;
23
    private $description;
24
    private $createdAt;
25
26 3
    public static function create(array $data): self
27
    {
28 3
        $model = new self();
29 3
        $model->id = $data['id'] ?? null;
30 3
        $model->priority = $data['priority'] ?? null;
31 3
        $model->filter = $data['expression'] ?? null;
32 3
        $model->actions = Action::createMultiple($data['actions'] ?? []);
33 3
        $model->description = $data['description'] ?? null;
34 3
        $model->createdAt = isset($data['created_at']) ? new \DateTimeImmutable($data['created_at']) : null;
35
36 3
        return $model;
37
    }
38
39 3
    private function __construct()
40
    {
41 3
    }
42
43
    public function getId(): ?string
44
    {
45
        return $this->id;
46
    }
47
48
    /**
49
     * @return Action[]
50
     */
51
    public function getActions(): array
52
    {
53
        return $this->actions;
54
    }
55
56 3
    public function getDescription(): ?string
57
    {
58 3
        return $this->description;
59
    }
60
61
    public function getFilter(): ?string
62
    {
63
        return $this->filter;
64
    }
65
66
    public function getPriority(): ?int
67
    {
68
        return $this->priority;
69
    }
70
71
    public function getCreatedAt(): \DateTimeImmutable
72
    {
73
        return $this->createdAt;
74
    }
75
}
76