This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 | |||
9 | /** |
||
10 | * AnalyticsConfigRepository |
||
11 | * |
||
12 | * This class was generated by the Doctrine ORM. Add your own custom |
||
13 | * repository methods below. |
||
14 | */ |
||
15 | class AnalyticsConfigRepository extends EntityRepository |
||
16 | { |
||
17 | /** |
||
18 | * Get the first config from the database, creates a new entry if the config doesn't exist yet |
||
19 | * |
||
20 | * @return AnalyticsConfig $config |
||
21 | */ |
||
22 | public function findFirst($createNew = true) |
||
23 | { |
||
24 | // Backwards compatibility: select the first config, still used in the dashboard, specified config ids are set in the dashboard collection bundle |
||
25 | $em = $this->getEntityManager(); |
||
26 | $query = $em->createQuery('SELECT c FROM KunstmaanDashboardBundle:AnalyticsConfig c'); |
||
27 | $result = $query->getResult(); |
||
28 | // if no configs exist, create a new one |
||
29 | if (!$result && $createNew) { |
||
30 | return $this->createConfig(); |
||
31 | } |
||
32 | |||
33 | if ($result) { |
||
34 | return $result[0]; |
||
35 | } |
||
36 | |||
37 | return false; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Get the default overviews for a config |
||
42 | * |
||
43 | * @return AnalyticsConfig $config |
||
0 ignored issues
–
show
|
|||
44 | */ |
||
45 | public function findDefaultOverviews($config) |
||
46 | { |
||
47 | $em = $this->getEntityManager(); |
||
48 | |||
49 | return $em->getRepository(AnalyticsOverview::class) |
||
50 | ->findBy(array( |
||
51 | 'config' => $config, |
||
52 | 'segment' => null, |
||
53 | )); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Create a new config |
||
58 | * |
||
59 | * @return AnalyticsConfig |
||
60 | */ |
||
61 | public function createConfig() |
||
62 | { |
||
63 | $em = $this->getEntityManager(); |
||
64 | |||
65 | $config = new AnalyticsConfig(); |
||
66 | $em->persist($config); |
||
67 | $em->flush(); |
||
68 | |||
69 | $this->getEntityManager()->getRepository(AnalyticsOverview::class)->addOverviews($config); |
||
70 | |||
71 | return $config; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Flush a config |
||
76 | * |
||
77 | * @param int $id the config id |
||
0 ignored issues
–
show
Should the type for parameter
$id 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...
|
|||
78 | */ |
||
79 | public function flushConfig($id = false) |
||
80 | { |
||
81 | $em = $this->getEntityManager(); |
||
82 | |||
83 | // Backward compatibilty to flush overviews without a config set |
||
84 | if (!$id) { |
||
0 ignored issues
–
show
The expression
$id of type false|integer is loosely compared to false ; 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...
|
|||
85 | $overviewRepository = $em->getRepository(AnalyticsOverview::class); |
||
86 | foreach ($overviewRepository->findAll() as $overview) { |
||
87 | $em->remove($overview); |
||
88 | } |
||
89 | $em->flush(); |
||
90 | |||
91 | return; |
||
92 | } |
||
93 | |||
94 | $config = $id ? $this->find($id) : $this->findFirst(); |
||
95 | foreach ($config->getOverviews() as $overview) { |
||
96 | $em->remove($overview); |
||
97 | } |
||
98 | foreach ($config->getSegments() as $segment) { |
||
99 | $em->remove($segment); |
||
100 | } |
||
101 | $em->flush(); |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * Update the timestamp when data is collected |
||
106 | * |
||
107 | * @param int id |
||
108 | */ |
||
109 | public function setUpdated($id = false) |
||
110 | { |
||
111 | $em = $this->getEntityManager(); |
||
112 | $config = $id ? $this->find($id) : $this->findFirst(); |
||
113 | $config->setLastUpdate(new \DateTime()); |
||
114 | $em->persist($config); |
||
115 | $em->flush(); |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * saves the token |
||
120 | * |
||
121 | * @param string $token |
||
122 | */ |
||
123 | public function saveToken($token, $id = false) |
||
124 | { |
||
125 | $em = $this->getEntityManager(); |
||
126 | $config = $id ? $this->find($id) : $this->findFirst(); |
||
127 | $config->setToken($token); |
||
128 | $em->persist($config); |
||
129 | $em->flush(); |
||
130 | } |
||
131 | |||
132 | /** |
||
133 | * saves the property id |
||
134 | * |
||
135 | * @param string $propertyId |
||
136 | */ |
||
137 | public function savePropertyId($propertyId, $id = false) |
||
138 | { |
||
139 | $em = $this->getEntityManager(); |
||
140 | $config = $id ? $this->find($id) : $this->findFirst(); |
||
141 | $config->setPropertyId($propertyId); |
||
142 | $em->persist($config); |
||
143 | $em->flush(); |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * saves the account id |
||
148 | * |
||
149 | * @param string $accountId |
||
150 | */ |
||
151 | public function saveAccountId($accountId, $id = false) |
||
152 | { |
||
153 | $em = $this->getEntityManager(); |
||
154 | $config = $id ? $this->find($id) : $this->findFirst(); |
||
155 | $config->setAccountId($accountId); |
||
156 | $em->persist($config); |
||
157 | $em->flush(); |
||
158 | } |
||
159 | |||
160 | /** |
||
161 | * saves the profile id |
||
162 | * |
||
163 | * @param string $profileId |
||
164 | */ |
||
165 | View Code Duplication | public function saveProfileId($profileId, $id = false) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
166 | { |
||
167 | $em = $this->getEntityManager(); |
||
168 | $config = $id ? $this->find($id) : $this->findFirst(); |
||
169 | $config->setProfileId($profileId); |
||
170 | $em->persist($config); |
||
171 | $em->flush(); |
||
172 | } |
||
173 | |||
174 | /** |
||
175 | * saves the config name |
||
176 | * |
||
177 | * @param string $profileId |
||
0 ignored issues
–
show
There is no parameter named
$profileId . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not.
Loading history...
|
|||
178 | */ |
||
179 | View Code Duplication | public function saveConfigName($name, $id = false) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
180 | { |
||
181 | $em = $this->getEntityManager(); |
||
182 | $config = $id ? $this->find($id) : $this->findFirst(); |
||
183 | $config->setName($name); |
||
184 | $em->persist($config); |
||
185 | $em->flush(); |
||
186 | } |
||
187 | |||
188 | /** |
||
189 | * Resets the profile id |
||
190 | * |
||
191 | * @param int id |
||
192 | */ |
||
193 | View Code Duplication | public function resetProfileId($id = false) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
194 | { |
||
195 | $em = $this->getEntityManager(); |
||
196 | $config = $id ? $this->find($id) : $this->findFirst(); |
||
197 | $config->setProfileId(''); |
||
198 | $em->persist($config); |
||
199 | $em->flush(); |
||
200 | } |
||
201 | |||
202 | /** |
||
203 | * Resets the account id, property id and profile id |
||
204 | * |
||
205 | * @param int id |
||
206 | */ |
||
207 | public function resetPropertyId($id = false) |
||
208 | { |
||
209 | $em = $this->getEntityManager(); |
||
210 | $config = $id ? $this->find($id) : $this->findFirst(); |
||
211 | $config->setAccountId(''); |
||
212 | $config->setProfileId(''); |
||
213 | $config->setPropertyId(''); |
||
214 | $em->persist($config); |
||
215 | $em->flush(); |
||
216 | } |
||
217 | } |
||
218 |
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.