AnalyticsOverview   A
last analyzed

Complexity

Total Complexity 39

Size/Duplication

Total Lines 526
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 39
lcom 2
cbo 2
dl 0
loc 526
ccs 90
cts 90
cp 1
rs 9.28
c 0
b 0
f 0

35 Methods

Rating   Name   Duplication   Size   Complexity  
A getReturningUsersPercentage() 0 4 2
A getNewUsersPercentage() 0 4 2
A getConfig() 0 4 1
A setConfig() 0 6 1
A getSegment() 0 4 1
A setSegment() 0 6 1
A setGoals() 0 6 1
A getGoals() 0 4 1
A getActiveGoals() 0 11 3
A setChartData() 0 6 1
A getChartData() 0 4 1
A setNewUsers() 0 6 1
A getNewUsers() 0 4 1
A setReturningUsers() 0 6 1
A getReturningUsers() 0 4 1
A setTitle() 0 6 1
A getTitle() 0 4 1
A setStartOffset() 0 6 1
A getStartOffset() 0 4 1
A setTimespan() 0 6 1
A getTimespan() 0 4 1
A setSessions() 0 6 1
A getSessions() 0 4 1
A getUsers() 0 4 1
A setUsers() 0 6 1
A setPageviews() 0 6 1
A getPageviews() 0 4 1
A setPagesPerSession() 0 6 1
A getPagesPerSession() 0 4 1
A setAvgSessionDuration() 0 6 1
A getAvgSessionDuration() 0 4 1
A setUseYear() 0 6 1
A getUseYear() 0 4 1
A setChartDataMaxValue() 0 6 1
A getChartDataMaxValue() 0 4 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
     * @ORM\ManyToOne(targetEntity="AnalyticsConfig", inversedBy="overviews")
18
     * @ORM\JoinColumn(name="config_id", referencedColumnName="id")
19
     */
20
    private $config;
21
22
    /**
23
     * @ORM\ManyToOne(targetEntity="AnalyticsSegment", inversedBy="overviews")
24
     * @ORM\JoinColumn(name="segment_id", referencedColumnName="id", nullable=true)
25
     */
26
    private $segment;
27
28
    /**
29
     * @ORM\OneToMany(targetEntity="AnalyticsGoal", mappedBy="overview", cascade={"persist", "remove"})
30
     * @ORM\OrderBy({"name" = "ASC"})
31
     */
32
    private $goals;
33
34
    /**
35
     * @var string
36
     *
37
     * @ORM\Column(name="title", type="string", length=255)
38
     */
39
    private $title;
40
41
    /**
42
     * @var int
43
     *
44
     * @ORM\Column(name="timespan", type="integer")
45
     */
46
    private $timespan;
47
48
    /**
49
     * @var int
50
     *
51
     * @ORM\Column(name="start_days_ago", type="integer")
52
     */
53
    private $startOffset = 0;
54
55
    /**
56
     * @var bool
57
     *
58
     * @ORM\Column(name="use_year", type="boolean")
59
     */
60
    private $useYear = false;
61
62
    /**
63
     * @var int
64
     *
65
     * @ORM\Column(name="sessions", type="integer")
66
     */
67
    private $sessions = 0;
68
69
    /**
70
     * @var int
71
     *
72
     * @ORM\Column(name="users", type="integer")
73
     */
74
    private $users = 0;
75
76
    /**
77
     * @var int
78
     *
79
     * @ORM\Column(name="returning_users", type="integer")
80
     */
81
    private $returningUsers = 0;
82
83
    /**
84
     * @var float
85
     *
86
     * @ORM\Column(name="new_users", type="float")
87
     */
88
    private $newUsers = 0;
89
90
    /**
91
     * @var int
92
     *
93
     * @ORM\Column(name="pageviews", type="integer")
94
     */
95
    private $pageviews = 0;
96
97
    /**
98
     * @var float
99
     *
100
     * @ORM\Column(name="pages_per_session", type="float")
101
     */
102
    private $pagesPerSession = 0;
103
104
    /**
105
     * @var int
106
     *
107
     * @ORM\Column(name="chart_data_max_value", type="integer")
108
     */
109
    private $chartDataMaxValue = 0;
110
111
    /**
112
     * @var string
113
     *
114
     * @ORM\Column(name="avg_session_duration", type="string")
115
     */
116
    private $avgSessionDuration = 0;
117
118
    /**
119
     * @var array
120
     *
121
     * @ORM\Column(name="chart_data", type="text")
122
     */
123
    private $chartData = '';
124
125
    /**
126
     * Get percentage of returning users
127
     *
128
     * @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...
129
     */
130 1
    public function getReturningUsersPercentage()
131
    {
132 1
        return $this->returningUsers ? round(($this->returningUsers / $this->sessions) * 100) : 0;
133
    }
134
135
    /**
136
     * Get percentage of new users
137
     *
138
     * @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...
139
     */
140 1
    public function getNewUsersPercentage()
141
    {
142 1
        return $this->newUsers ? round(($this->newUsers / $this->sessions) * 100) : 0;
143
    }
144
145
    /**
146
     * Get config
147
     *
148
     * @return int
149
     */
150 1
    public function getConfig()
151
    {
152 1
        return $this->config;
153
    }
154
155
    /**
156
     * Set config
157
     *
158
     * @param int $config
159
     *
160
     * @return AnalyticsTopReferrals
0 ignored issues
show
Documentation introduced by
Should the return type not be AnalyticsOverview?

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...
161
     */
162 1
    public function setConfig($config)
163
    {
164 1
        $this->config = $config;
165
166 1
        return $this;
167
    }
168
169
    /**
170
     * Get segment
171
     *
172
     * @return int
173
     */
174 1
    public function getSegment()
175
    {
176 1
        return $this->segment;
177
    }
178
179
    /**
180
     * Set segment
181
     *
182
     * @param int $segment
183
     *
184
     * @return AnalyticsTopReferrals
0 ignored issues
show
Documentation introduced by
Should the return type not be AnalyticsOverview?

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...
185
     */
186 1
    public function setSegment($segment)
187
    {
188 1
        $this->segment = $segment;
189
190 1
        return $this;
191
    }
192
193
    /**
194
     * Set goals
195
     *
196
     * @param array $goals
197
     *
198
     * @return $this
199
     */
200 1
    public function setGoals($goals)
201
    {
202 1
        $this->goals = $goals;
203
204 1
        return $this;
205
    }
206
207
    /**
208
     * Get goals
209
     *
210
     * @return AnalyticsGoal[]
211
     */
212 1
    public function getGoals()
213
    {
214 1
        return $this->goals;
215
    }
216
217
    /**
218
     * @return array
219
     */
220 1
    public function getActiveGoals()
221
    {
222 1
        $goals = array();
223 1
        foreach ($this->getGoals() as $goal) {
224 1
            if ($goal->getVisits()) {
225 1
                $goals[] = $goal;
226
            }
227
        }
228
229 1
        return $goals;
230
    }
231
232
    /**
233
     * Set chartData
234
     *
235
     * @param array $chartData
236
     *
237
     * @return $this
238
     */
239 1
    public function setChartData($chartData)
240
    {
241 1
        $this->chartData = $chartData;
242
243 1
        return $this;
244
    }
245
246
    /**
247
     * Get chartData
248
     *
249
     * @return array
250
     */
251 1
    public function getChartData()
252
    {
253 1
        return $this->chartData;
254
    }
255
256
    /**
257
     * Set newUsers
258
     *
259
     * @param float $newUsers
260
     *
261
     * @return AnalyticsOverview
262
     */
263 1
    public function setNewUsers($newUsers)
264
    {
265 1
        $this->newUsers = $newUsers;
266
267 1
        return $this;
268
    }
269
270
    /**
271
     * Get newUsers
272
     *
273
     * @return float
274
     */
275 1
    public function getNewUsers()
276
    {
277 1
        return $this->newUsers;
278
    }
279
280
    /**
281
     * @param int $returningUsers
282
     *
283
     * @return $this
284
     */
285 1
    public function setReturningUsers($returningUsers)
286
    {
287 1
        $this->returningUsers = $returningUsers;
288
289 1
        return $this;
290
    }
291
292
    /**
293
     * @return int
294
     */
295 1
    public function getReturningUsers()
296
    {
297 1
        return $this->returningUsers;
298
    }
299
300
    /**
301
     * Set title
302
     *
303
     * @param string $title
304
     *
305
     * @return AnalyticsOverview
306
     */
307 1
    public function setTitle($title)
308
    {
309 1
        $this->title = $title;
310
311 1
        return $this;
312
    }
313
314
    /**
315
     * Get title
316
     *
317
     * @return string
318
     */
319 1
    public function getTitle()
320
    {
321 1
        return $this->title;
322
    }
323
324
    /**
325
     * Set startOffset
326
     *
327
     * @param int $startOffset
328
     *
329
     * @return AnalyticsOverview
330
     */
331 1
    public function setStartOffset($startOffset)
332
    {
333 1
        $this->startOffset = $startOffset;
334
335 1
        return $this;
336
    }
337
338
    /**
339
     * Get startOffset
340
     *
341
     * @return int
342
     */
343 1
    public function getStartOffset()
344
    {
345 1
        return $this->startOffset;
346
    }
347
348
    /**
349
     * Set timespan
350
     *
351
     * @param int $timespan
352
     *
353
     * @return AnalyticsOverview
354
     */
355 1
    public function setTimespan($timespan)
356
    {
357 1
        $this->timespan = $timespan;
358
359 1
        return $this;
360
    }
361
362
    /**
363
     * Get timespan
364
     *
365
     * @return int
366
     */
367 1
    public function getTimespan()
368
    {
369 1
        return $this->timespan;
370
    }
371
372
    /**
373
     * Set sessions
374
     *
375
     * @param int $sessions
376
     *
377
     * @return AnalyticsOverview
378
     */
379 1
    public function setSessions($sessions)
380
    {
381 1
        $this->sessions = $sessions;
382
383 1
        return $this;
384
    }
385
386
    /**
387
     * Get sessions
388
     *
389
     * @return int
390
     */
391 1
    public function getSessions()
392
    {
393 1
        return $this->sessions;
394
    }
395
396
    /**
397
     * Get Users
398
     *
399
     * @return int
400
     */
401 1
    public function getUsers()
402
    {
403 1
        return $this->users;
404
    }
405
406
    /**
407
     * Set users
408
     *
409
     * @param int $users
410
     *
411
     * @return AnalyticsOverview
412
     */
413 1
    public function setUsers($users)
414
    {
415 1
        $this->users = $users;
416
417 1
        return $this;
418
    }
419
420
    /**
421
     * Set pageviews
422
     *
423
     * @param int $pageviews
424
     *
425
     * @return AnalyticsOverview
426
     */
427 1
    public function setPageviews($pageviews)
428
    {
429 1
        $this->pageviews = $pageviews;
430
431 1
        return $this;
432
    }
433
434
    /**
435
     * Get pageviews
436
     *
437
     * @return int
438
     */
439 1
    public function getPageviews()
440
    {
441 1
        return $this->pageviews;
442
    }
443
444
    /**
445
     * Set pagesPerSession
446
     *
447
     * @param float $pagesPerSession
448
     *
449
     * @return AnalyticsOverview
450
     */
451 1
    public function setPagesPerSession($pagesPerSession)
452
    {
453 1
        $this->pagesPerSession = $pagesPerSession;
454
455 1
        return $this;
456
    }
457
458
    /**
459
     * Get pagesPerSession
460
     *
461
     * @return float
462
     */
463 1
    public function getPagesPerSession()
464
    {
465 1
        return $this->pagesPerSession;
466
    }
467
468
    /**
469
     * Set avgSessionDuration
470
     *
471
     * @param int $avgSessionDuration
472
     *
473
     * @return AnalyticsOverview
474
     */
475 1
    public function setAvgSessionDuration($avgSessionDuration)
476
    {
477 1
        $this->avgSessionDuration = $avgSessionDuration;
0 ignored issues
show
Documentation Bug introduced by
The property $avgSessionDuration was declared of type string, but $avgSessionDuration is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
478
479 1
        return $this;
480
    }
481
482
    /**
483
     * Get avgSessionDuration
484
     *
485
     * @return string
486
     */
487 1
    public function getAvgSessionDuration()
488
    {
489 1
        return $this->avgSessionDuration;
490
    }
491
492
    /**
493
     * Set useYear
494
     *
495
     * @param int $useYear
496
     *
497
     * @return AnalyticsOverview
498
     */
499 1
    public function setUseYear($useYear)
500
    {
501 1
        $this->useYear = $useYear;
0 ignored issues
show
Documentation Bug introduced by
The property $useYear was declared of type boolean, but $useYear is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
502
503 1
        return $this;
504
    }
505
506
    /**
507
     * Get useYear
508
     *
509
     * @return int
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean?

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...
510
     */
511 1
    public function getUseYear()
512
    {
513 1
        return $this->useYear;
514
    }
515
516
    /**
517
     * Set chartDataMaxValue
518
     *
519
     * @param int $chartDataMaxValue
520
     *
521
     * @return AnalyticsOverview
522
     */
523 1
    public function setChartDataMaxValue($chartDataMaxValue)
524
    {
525 1
        $this->chartDataMaxValue = $chartDataMaxValue;
526
527 1
        return $this;
528
    }
529
530
    /**
531
     * Get chartDataMaxValue
532
     *
533
     * @return int
534
     */
535 1
    public function getChartDataMaxValue()
536
    {
537 1
        return $this->chartDataMaxValue;
538
    }
539
}
540