Completed
Push — master ( 770316...74fc07 )
by Jeroen
09:08 queued 02:44
created

Repository/AnalyticsOverviewRepository.php (14 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\DashboardBundle\Repository;
4
5
use Doctrine\ORM\EntityRepository;
6
use Kunstmaan\DashboardBundle\Entity\AnalyticsConfig;
7
use Kunstmaan\DashboardBundle\Entity\AnalyticsOverview;
8
use Kunstmaan\DashboardBundle\Entity\AnalyticsSegment;
9
10
class AnalyticsOverviewRepository extends EntityRepository
11
{
12
    /**
13
     * Get then default overviews (without a segment)
14
     *
15
     * @return array
16
     */
17
    public function getDefaultOverviews($config = false)
18
    {
19
        $em = $this->getEntityManager();
20
        $dql = 'SELECT o FROM KunstmaanDashboardBundle:AnalyticsOverview o WHERE o.segment IS NULL';
21
        if ($config) {
22
            $dql .= " AND o.config = $config";
23
        }
24
25
        $query = $em->createQuery($dql);
26
27
        return $query->getResult();
28
    }
29
30
    /**
31
     * Add overviews for a config and optionally a segment
32
     *
33
     * @param AnalyticsConfig  $config
34
     * @param AnalyticsSegment $segment
0 ignored issues
show
Should the type for parameter $segment not be AnalyticsSegment|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
35
     */
36
    public function addOverviews(&$config, &$segment = null)
37
    {
38
        $em = $this->getEntityManager();
39
40
        $today = new AnalyticsOverview();
41
        $today->setTitle('dashboard.ga.tab.today');
42
        $today->setTimespan(0);
43
        $today->setStartOffset(0);
44
        $today->setConfig($config);
0 ignored issues
show
$config is of type object<Kunstmaan\Dashboa...Entity\AnalyticsConfig>, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
45
        $today->setSegment($segment);
0 ignored issues
show
$segment is of type object<Kunstmaan\Dashboa...\AnalyticsSegment>|null, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
46
        $em->persist($today);
47
48
        $yesterday = new AnalyticsOverview();
49
        $yesterday->setTitle('dashboard.ga.tab.yesterday');
50
        $yesterday->setTimespan(1);
51
        $yesterday->setStartOffset(1);
52
        $yesterday->setConfig($config);
0 ignored issues
show
$config is of type object<Kunstmaan\Dashboa...Entity\AnalyticsConfig>, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
53
        $yesterday->setSegment($segment);
0 ignored issues
show
$segment is of type object<Kunstmaan\Dashboa...\AnalyticsSegment>|null, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
54
        $em->persist($yesterday);
55
56
        $week = new AnalyticsOverview();
57
        $week->setTitle('dashboard.ga.tab.last_7_days');
58
        $week->setTimespan(7);
59
        $week->setStartOffset(1);
60
        $week->setConfig($config);
0 ignored issues
show
$config is of type object<Kunstmaan\Dashboa...Entity\AnalyticsConfig>, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
61
        $week->setSegment($segment);
0 ignored issues
show
$segment is of type object<Kunstmaan\Dashboa...\AnalyticsSegment>|null, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
62
        $em->persist($week);
63
64
        $month = new AnalyticsOverview();
65
        $month->setTitle('dashboard.ga.tab.last_30_days');
66
        $month->setTimespan(30);
67
        $month->setStartOffset(1);
68
        $month->setConfig($config);
0 ignored issues
show
$config is of type object<Kunstmaan\Dashboa...Entity\AnalyticsConfig>, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
69
        $month->setSegment($segment);
0 ignored issues
show
$segment is of type object<Kunstmaan\Dashboa...\AnalyticsSegment>|null, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
70
        $em->persist($month);
71
72
        $year = new AnalyticsOverview();
73
        $year->setTitle('dashboard.ga.tab.last_12_months');
74
        $year->setTimespan(365);
75
        $year->setStartOffset(1);
76
        $year->setConfig($config);
0 ignored issues
show
$config is of type object<Kunstmaan\Dashboa...Entity\AnalyticsConfig>, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
77
        $year->setSegment($segment);
0 ignored issues
show
$segment is of type object<Kunstmaan\Dashboa...\AnalyticsSegment>|null, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
78
        $em->persist($year);
79
80
        $yearToDate = new AnalyticsOverview();
81
        $yearToDate->setTitle('dashboard.ga.tab.year_to_date');
82
        $yearToDate->setTimespan(365);
83
        $yearToDate->setStartOffset(1);
84
        $yearToDate->setConfig($config);
0 ignored issues
show
$config is of type object<Kunstmaan\Dashboa...Entity\AnalyticsConfig>, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
85
        $yearToDate->setSegment($segment);
0 ignored issues
show
$segment is of type object<Kunstmaan\Dashboa...\AnalyticsSegment>|null, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
86
        $yearToDate->setUseYear(true);
0 ignored issues
show
true is of type boolean, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
87
        $em->persist($yearToDate);
88
89
        $em->flush();
90
    }
91
}
92