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 | /** |
||
11 | * AnalyticsSegmentRepository |
||
12 | * |
||
13 | * This class was generated by the Doctrine ORM. Add your own custom |
||
14 | * repository methods below. |
||
15 | */ |
||
16 | class AnalyticsSegmentRepository extends EntityRepository |
||
17 | { |
||
18 | /** |
||
19 | * Get a segment |
||
20 | * |
||
21 | * @param int $id |
||
22 | * |
||
23 | * @return AnalyticsOverview|bool |
||
0 ignored issues
–
show
|
|||
24 | */ |
||
25 | public function deleteSegment($id) |
||
26 | { |
||
27 | $em = $this->getEntityManager(); |
||
28 | $qb = $em->createQueryBuilder(); |
||
29 | $qb->select('s') |
||
30 | ->from('KunstmaanDashboardBundle:AnalyticsSegment', 's') |
||
31 | ->where('s.id = :id') |
||
32 | ->setParameter('id', $id); |
||
33 | |||
34 | $results = $qb->getQuery()->getResult(); |
||
35 | if ($results) { |
||
36 | $em->remove($results[0]); |
||
37 | $em->flush(); |
||
38 | } |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Initialise a segment by adding new overviews if they don't exist yet |
||
43 | * |
||
44 | * @param AnalyticsSegment $segment |
||
45 | * @param int $configId |
||
0 ignored issues
–
show
Should the type for parameter
$configId not be false|integer ?
This check looks for 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...
|
|||
46 | */ |
||
47 | public function initSegment($segment, $configId = false) |
||
48 | { |
||
49 | if (!\count($segment->getOverviews()->toArray())) { |
||
50 | if ($configId) { |
||
0 ignored issues
–
show
The expression
$configId of type false|integer is loosely compared to true ; this is ambiguous if the integer can be zero. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like For 0 == false // true
0 == null // true
123 == false // false
123 == null // false
// It is often better to use strict comparison
0 === false // false
0 === null // false
Loading history...
|
|||
51 | $config = $this->getEntityManager()->getRepository(AnalyticsConfig::class)->find($configId); |
||
52 | } else { |
||
53 | $config = $this->getEntityManager()->getRepository(AnalyticsConfig::class)->findFirst(); |
||
54 | } |
||
55 | $this->getEntityManager()->getRepository(AnalyticsOverview::class)->addOverviews($config, $segment); |
||
56 | } |
||
57 | } |
||
58 | } |
||
59 |
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.