1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Schema Class for output data. |
4
|
|
|
*/ |
5
|
|
|
namespace Graviton\AnalyticsBundle\Model; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Schema |
9
|
|
|
* |
10
|
|
|
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors> |
11
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
12
|
|
|
* @link http://swisscom.ch |
13
|
|
|
*/ |
14
|
|
|
class AnalyticModel |
15
|
|
|
{ |
16
|
|
|
protected $collection; |
17
|
|
|
protected $route; |
18
|
|
|
protected $aggregate; |
19
|
|
|
protected $schema; |
20
|
|
|
protected $type; |
21
|
|
|
protected $cacheTime; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* String collection |
25
|
|
|
* @return mixed |
26
|
|
|
*/ |
27
|
|
|
public function getCollection() |
28
|
|
|
{ |
29
|
|
|
return $this->collection; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Set value of collection |
34
|
|
|
* @param mixed $collection string name |
35
|
|
|
* @return void |
36
|
|
|
*/ |
37
|
|
|
public function setCollection($collection) |
38
|
|
|
{ |
39
|
|
|
$this->collection = $collection; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Route path |
44
|
|
|
* @return mixed |
45
|
|
|
*/ |
46
|
|
|
public function getRoute() |
47
|
|
|
{ |
48
|
|
|
return $this->route; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Set path |
53
|
|
|
* @param mixed $route string route |
54
|
|
|
* @return void |
55
|
|
|
*/ |
56
|
|
|
public function setRoute($route) |
57
|
|
|
{ |
58
|
|
|
$this->route = $route; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Mongodb Aggregates |
63
|
|
|
* @return mixed |
64
|
|
|
*/ |
65
|
|
|
public function getAggregate() |
66
|
|
|
{ |
67
|
|
|
return $this->aggregate ?: []; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Set mongodb query |
72
|
|
|
* @param mixed $aggregate object type for query data |
73
|
|
|
* @return void |
74
|
|
|
*/ |
75
|
|
|
public function setAggregate($aggregate) |
76
|
|
|
{ |
77
|
|
|
$this->aggregate = $aggregate; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Schema for response |
82
|
|
|
* @return mixed |
83
|
|
|
*/ |
84
|
|
|
public function getSchema() |
85
|
|
|
{ |
86
|
|
|
return $this->schema; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Schema data |
91
|
|
|
* @param mixed $schema object schema |
92
|
|
|
* @return void |
93
|
|
|
*/ |
94
|
|
|
public function setSchema($schema) |
95
|
|
|
{ |
96
|
|
|
$this->schema = $schema; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Type of response data |
101
|
|
|
* @return mixed |
102
|
|
|
*/ |
103
|
|
|
public function getType() |
104
|
|
|
{ |
105
|
|
|
return $this->type; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Type for representation |
110
|
|
|
* @param mixed $type string view |
111
|
|
|
* @return void |
112
|
|
|
*/ |
113
|
|
|
public function setType($type) |
114
|
|
|
{ |
115
|
|
|
$this->type = $type; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Time for this route data to be cached |
120
|
|
|
* @return mixed |
|
|
|
|
121
|
|
|
*/ |
122
|
|
|
public function getCacheTime() |
123
|
|
|
{ |
124
|
|
|
return $this->cacheTime; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Time for this route data to be cached |
129
|
|
|
* @param integer $cacheTime seconds to be cached |
130
|
|
|
* @return void |
131
|
|
|
*/ |
132
|
|
|
public function setCacheTime($cacheTime) |
133
|
|
|
{ |
134
|
|
|
$this->cacheTime = (int) $cacheTime; |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.