ChartConfig::getChartProvider()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Copyright (c) 2014 - Arno van Rossum <[email protected]>
4
 *
5
 * Permission is hereby granted, free of charge, to any person obtaining a copy
6
 * of this software and associated documentation files (the "Software"), to deal
7
 * in the Software without restriction, including without limitation the rights
8
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the Software is
10
 * furnished to do so, subject to the following conditions:
11
 *
12
 * The above copyright notice and this permission notice shall be included in
13
 * all copies or substantial portions of the Software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
 * THE SOFTWARE.
22
 */
23
24
namespace OCA\ocUsageCharts\Entity;
25
26
/**
27
 * @author Arno van Rossum <[email protected]>
28
 */
29
class ChartConfig
30
{
31
    /**
32
     * @var integer
33
     */
34
    private $id;
35
36
    /**
37
     * @var \DateTime
38
     */
39
    private $date;
40
41
    /**
42
     * @var string
43
     */
44
    private $username;
45
46
    /**
47
     * @var string
48
     */
49
    private $chartType;
50
51
    /**
52
     * @var string
53
     */
54
    private $chartProvider;
55
56
    /**
57
     * @var string
58
     */
59
    private $metaData;
60
61
    /**
62
     * @param integer $id
63
     * @param \DateTime $date
64
     * @param string $username
65
     * @param string $chartType
66
     * @param string $chartProvider
67
     * @param string $metaData
68
     */
69
    public function __construct($id, \DateTime $date, $username, $chartType, $chartProvider = 'c3js', $metaData = '')
70
    {
71
        $this->id = $id;
72
        $this->date = $date;
73
        $this->username = $username;
74
        $this->chartType = $chartType;
75
        $this->chartProvider = $chartProvider;
76
        $this->metaData = $metaData;
77
    }
78
79
    /**
80
     * @return integer
81
     */
82
    public function getId()
83
    {
84
        return $this->id;
85
    }
86
87
    /**
88
     * @return \DateTime
89
     */
90
    public function getDate()
91
    {
92
        return $this->date;
93
    }
94
95
    /**
96
     * @return string
97
     */
98
    public function getUsername()
99
    {
100
        return $this->username;
101
    }
102
103
    /**
104
     * @return string
105
     */
106
    public function getChartType()
107
    {
108
        return $this->chartType;
109
    }
110
111
    /**
112
     * @return string
113
     */
114
    public function getChartProvider()
115
    {
116
        return $this->chartProvider;
117
    }
118
119
    /**
120
     * Metadata is possible to save externally
121
     *
122
     * @param string $data 255 chars max
123
     */
124
    public function setMetaData($data)
125
    {
126
        $this->metaData = $data;
127
    }
128
129
    /**
130
     * @return string
131
     */
132
    public function getMetaData()
133
    {
134
        return $this->metaData;
135
    }
136
137
    /**
138
     * @param array $row
139
     * @return ChartConfig
140
     */
141
    public static function fromRow($row)
142
    {
143
        return new ChartConfig($row['id'], new \Datetime($row['created']), $row['username'], $row['charttype'], $row['chartprovider'], $row['metadata']);
144
    }
145
146
}