Application::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 8
nc 1
nop 3
1
<?php
2
/**
3
 * This file is part of the fnayou/instapush-php project.
4
 *
5
 * Copyright (c) 2017. Aymen FNAYOU <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Fnayou\InstapushPHP\Model;
12
13
/**
14
 * Model Application.
15
 */
16
class Application implements FromArrayInterface
17
{
18
    /** @var string */
19
    private $title;
20
21
    /** @var string */
22
    private $appId;
23
24
    /** @var string */
25
    private $appSecret;
26
27
    /**
28
     * @param string $title
29
     * @param string $appId
30
     * @param string $appSecret
31
     */
32
    public function __construct(
33
        string $title,
34
        string $appId = null,
35
        string $appSecret = null
36
    ) {
37
        $this
38
            ->setTitle($title)
39
            ->setAppId($appId)
40
            ->setAppSecret($appSecret);
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function getTitle()
47
    {
48
        return $this->title;
49
    }
50
51
    /**
52
     * @param string $title
53
     *
54
     * @return $this
55
     */
56
    public function setTitle(string $title)
57
    {
58
        $this->title = $title;
59
60
        return $this;
61
    }
62
63
    /**
64
     * @return string
65
     */
66
    public function getAppId()
67
    {
68
        return $this->appId;
69
    }
70
71
    /**
72
     * @param string $appId
73
     *
74
     * @return $this
75
     */
76
    public function setAppId(string $appId = null)
77
    {
78
        $this->appId = $appId;
79
80
        return $this;
81
    }
82
83
    /**
84
     * @return string
85
     */
86
    public function getAppSecret()
87
    {
88
        return $this->appSecret;
89
    }
90
91
    /**
92
     * @param string $appSecret
93
     *
94
     * @return $this
95
     */
96
    public function setAppSecret(string $appSecret = null)
97
    {
98
        $this->appSecret = $appSecret;
99
100
        return $this;
101
    }
102
103
    /**
104
     * {@inheritdoc}
105
     */
106
    public static function fromArray(array $data)
107
    {
108
        return new static(
109
            $data['title'],
110
            $data['appID'],
111
            $data['appSecret']
112
        );
113
    }
114
115
    /**
116
     * @return array
117
     */
118
    public function toArray()
119
    {
120
        return [
121
            'title' => $this->getTitle(),
122
            'appID' => $this->getAppId(),
123
            'appSecret' => $this->getAppSecret(),
124
        ];
125
    }
126
}
127