Completed
Pull Request — 6.0 (#1872)
by Sander
102:24 queued 60:56
created

AnalyticsOverview::setPageViews()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Kunstmaan\DashboardBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Kunstmaan\AdminBundle\Entity\AbstractEntity;
7
8
/**
9
 * AnalyticsOverview
10
 *
11
 * @ORM\Table(name="kuma_analytics_overview")
12
 * @ORM\Entity(repositoryClass="Kunstmaan\DashboardBundle\Repository\AnalyticsOverviewRepository")
13
 */
14
class AnalyticsOverview extends AbstractEntity
15
{
16
    /**
17
     * @var AnalyticsConfig
18
     *
19
     * @ORM\ManyToOne(targetEntity="AnalyticsConfig", inversedBy="overviews")
20
     * @ORM\JoinColumn(name="config_id", referencedColumnName="id")
21
     */
22
    private $config;
23
24
    /**
25
     * @var AnalyticsSegment
26
     *
27
     * @ORM\ManyToOne(targetEntity="AnalyticsSegment", inversedBy="overviews")
28
     * @ORM\JoinColumn(name="segment_id", referencedColumnName="id", nullable=true)
29
     */
30
    private $segment;
31
32
    /**
33
     * @ORM\OneToMany(targetEntity="AnalyticsGoal", mappedBy="overview", cascade={"persist", "remove"})
34
     * @ORM\OrderBy({"name" = "ASC"})
35
     */
36
    private $goals;
37
38
    /**
39
     * @var string
40
     *
41
     * @ORM\Column(name="title", type="string", length=255)
42
     */
43
    private $title;
44
45
    /**
46
     * @var integer
47
     *
48
     * @ORM\Column(name="timespan", type="integer")
49
     */
50
    private $timespan;
51
52
    /**
53
     * @var integer
54
     *
55
     * @ORM\Column(name="start_days_ago", type="integer")
56
     */
57
    private $startOffset = 0;
58
59
    /**
60
     * @var boolean
61
     *
62
     * @ORM\Column(name="use_year", type="boolean")
63
     */
64
    private $useYear = false;
65
66
    /**
67
     * @var integer
68
     *
69
     * @ORM\Column(name="sessions", type="integer")
70
     */
71
    private $sessions = 0;
72
73
    /**
74
     * @var integer
75
     *
76
     * @ORM\Column(name="users", type="integer")
77
     */
78
    private $users = 0;
79
80
    /**
81
     * @var integer
82
     *
83
     * @ORM\Column(name="returning_users", type="integer")
84
     */
85
    private $returningUsers = 0;
86
87
    /**
88
     * @var float
89
     *
90
     * @ORM\Column(name="new_users", type="float")
91
     */
92
    private $newUsers = 0;
93
94
    /**
95
     * @var integer
96
     *
97
     * @ORM\Column(name="pageviews", type="integer")
98
     */
99
    private $pageViews = 0;
100
101
    /**
102
     * @var float
103
     *
104
     * @ORM\Column(name="pages_per_session", type="float")
105
     */
106
    private $pagesPerSession = 0;
107
108
    /**
109
     * @var integer
110
     *
111
     * @ORM\Column(name="chart_data_max_value", type="integer")
112
     */
113
    private $chartDataMaxValue = 0;
114
115
    /**
116
     * @var string
117
     *
118
     * @ORM\Column(name="avg_session_duration", type="string")
119
     */
120
    private $avgSessionDuration = 0;
121
122
    /**
123
     * @var string
124
     *
125
     * @ORM\Column(name="chart_data", type="text")
126
     */
127
    private $chartData = '';
128
129
    /**
130
     * Get percentage of returning users
131
     *
132
     * @return int
0 ignored issues
show
Documentation introduced by
Should the return type not be double|integer?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
133
     */
134
    public function getReturningUsersPercentage()
135
    {
136
        return $this->returningUsers ? round(($this->returningUsers / $this->sessions) * 100) : 0;
137
    }
138
139
    /**
140
     * Get percentage of new users
141
     *
142
     * @return int
0 ignored issues
show
Documentation introduced by
Should the return type not be double|integer?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
143
     */
144
    public function getNewUsersPercentage()
145
    {
146
        return $this->newUsers ? round(($this->newUsers / $this->sessions) * 100) : 0;
147
    }
148
149
    /**
150
     * @return AnalyticsConfig
151
     */
152
    public function getConfig()
153
    {
154
        return $this->config;
155
    }
156
157
    /**
158
     * @param AnalyticsConfig $config
159
     */
160
    public function setConfig($config)
161
    {
162
        $this->config = $config;
163
    }
164
165
    /**
166
     * @return AnalyticsSegment
167
     */
168
    public function getSegment()
169
    {
170
        return $this->segment;
171
    }
172
173
    /**
174
     * @param AnalyticsSegment $segment
175
     */
176
    public function setSegment($segment)
177
    {
178
        $this->segment = $segment;
179
    }
180
181
    /**
182
     * Set goals
183
     *
184
     * @param array $goals
185
     *
186
     * @return $this
187
     */
188
    public function setGoals($goals)
189
    {
190
        $this->goals = $goals;
191
192
        return $this;
193
    }
194
195
    /**
196
     * Get goals
197
     *
198
     * @return AnalyticsGoal[]
199
     */
200
    public function getGoals()
201
    {
202
        return $this->goals;
203
    }
204
205
    /**
206
     * @return array
207
     */
208
    public function getActiveGoals()
209
    {
210
        $goals = [];
211
        foreach ($this->getGoals() as $goal) {
212
            if ($goal->getVisits()) {
213
                $goals[] = $goal;
214
            }
215
        }
216
217
        return $goals;
218
    }
219
220
    /**
221
     * @return string
222
     */
223
    public function getTitle()
224
    {
225
        return $this->title;
226
    }
227
228
    /**
229
     * @param string $title
230
     */
231
    public function setTitle($title)
232
    {
233
        $this->title = $title;
234
    }
235
236
    /**
237
     * @return int
238
     */
239
    public function getTimespan()
240
    {
241
        return $this->timespan;
242
    }
243
244
    /**
245
     * @param int $timespan
246
     */
247
    public function setTimespan($timespan)
248
    {
249
        $this->timespan = $timespan;
250
    }
251
252
    /**
253
     * @return int
254
     */
255
    public function getStartOffset()
256
    {
257
        return $this->startOffset;
258
    }
259
260
    /**
261
     * @param int $startOffset
262
     */
263
    public function setStartOffset($startOffset)
264
    {
265
        $this->startOffset = $startOffset;
266
    }
267
268
    /**
269
     * @return bool
270
     */
271
    public function getUseYear()
272
    {
273
        return $this->useYear;
274
    }
275
276
    /**
277
     * @param bool $useYear
278
     */
279
    public function setUseYear($useYear)
280
    {
281
        $this->useYear = $useYear;
282
    }
283
284
    /**
285
     * @return int
286
     */
287
    public function getSessions()
288
    {
289
        return $this->sessions;
290
    }
291
292
    /**
293
     * @param int $sessions
294
     */
295
    public function setSessions($sessions)
296
    {
297
        $this->sessions = $sessions;
298
    }
299
300
    /**
301
     * @return int
302
     */
303
    public function getUsers()
304
    {
305
        return $this->users;
306
    }
307
308
    /**
309
     * @param int $users
310
     */
311
    public function setUsers($users)
312
    {
313
        $this->users = $users;
314
    }
315
316
    /**
317
     * @return int
318
     */
319
    public function getReturningUsers()
320
    {
321
        return $this->returningUsers;
322
    }
323
324
    /**
325
     * @param int $returningUsers
326
     */
327
    public function setReturningUsers($returningUsers)
328
    {
329
        $this->returningUsers = $returningUsers;
330
    }
331
332
    /**
333
     * @return float
334
     */
335
    public function getNewUsers()
336
    {
337
        return $this->newUsers;
338
    }
339
340
    /**
341
     * @param float $newUsers
342
     */
343
    public function setNewUsers($newUsers)
344
    {
345
        $this->newUsers = $newUsers;
346
    }
347
348
    /**
349
     * @return int
350
     */
351
    public function getPageViews()
352
    {
353
        return $this->pageViews;
354
    }
355
356
    /**
357
     * @param int $pageViews
358
     */
359
    public function setPageViews($pageViews)
360
    {
361
        $this->pageViews = $pageViews;
362
    }
363
364
    /**
365
     * @return float
366
     */
367
    public function getPagesPerSession()
368
    {
369
        return $this->pagesPerSession;
370
    }
371
372
    /**
373
     * @param float $pagesPerSession
374
     */
375
    public function setPagesPerSession($pagesPerSession)
376
    {
377
        $this->pagesPerSession = $pagesPerSession;
378
    }
379
380
    /**
381
     * @return int
382
     */
383
    public function getChartDataMaxValue()
384
    {
385
        return $this->chartDataMaxValue;
386
    }
387
388
    /**
389
     * @param int $chartDataMaxValue
390
     */
391
    public function setChartDataMaxValue($chartDataMaxValue)
392
    {
393
        $this->chartDataMaxValue = $chartDataMaxValue;
394
    }
395
396
    /**
397
     * @return string
398
     */
399
    public function getAvgSessionDuration()
400
    {
401
        return $this->avgSessionDuration;
402
    }
403
404
    /**
405
     * @param string $avgSessionDuration
406
     */
407
    public function setAvgSessionDuration($avgSessionDuration)
408
    {
409
        $this->avgSessionDuration = $avgSessionDuration;
410
    }
411
412
    /**
413
     * @return string
414
     */
415
    public function getChartData()
416
    {
417
        return $this->chartData;
418
    }
419
420
    /**
421
     * @param string $chartData
422
     */
423
    public function setChartData($chartData)
424
    {
425
        $this->chartData = $chartData;
426
    }
427
}
428