GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#61)
by Simone
02:15
created

BaseRepository::noExistsJoin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Mado\QueryBundle\Repositories;
4
5
use Doctrine\ORM\EntityRepository;
6
use Hateoas\Configuration\Route;
0 ignored issues
show
Bug introduced by
The type Hateoas\Configuration\Route was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Hateoas\Representation\Factory\PagerfantaFactory;
0 ignored issues
show
Bug introduced by
The type Hateoas\Representation\Factory\PagerfantaFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Mado\QueryBundle\Queries\QueryBuilderFactory;
9
use Mado\QueryBundle\Queries\QueryBuilderOptions;
10
use Mado\QueryBundle\Component\ConfigProvider;
11
use Pagerfanta\Adapter\DoctrineORMAdapter;
0 ignored issues
show
Bug introduced by
The type Pagerfanta\Adapter\DoctrineORMAdapter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Pagerfanta\Pagerfanta;
0 ignored issues
show
Bug introduced by
The type Pagerfanta\Pagerfanta was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Symfony\Component\HttpFoundation\Request;
14
15
class BaseRepository extends EntityRepository
16
{
17
    protected $fields;
18
19
    protected $request;
20
21
    protected $use_result_cache = false;
22
23
    protected $entityAlias;
24
25
    protected $route_name;
26
27
    protected $currentEntityAlias;
28
29
    protected $embeddedFields;
30
31
    protected $joins = [];
32
33
    protected $queryBuilderFactory;
34
35
    protected $queryOptions;
36 5
37
    protected $configProvider;
38 5
39
    public function __construct($manager, $class)
40 5
    {
41
        parent::__construct($manager, $class);
42 5
43 5
        $this->fields = array_keys($this->getClassMetadata()->fieldMappings);
44 5
45 5
        $entityName = explode('\\', strtolower($this->getEntityName()) );
46
        $entityName = $entityName[count($entityName)-1];
47 5
        $entityAlias = $entityName[0];
48 5
        $this->entityAlias = $entityAlias;
49
50
        $this->queryBuilderFactory = new QueryBuilderFactory($this->getEntityManager());
51
    }
52
53
    public function initFromQueryBuilderOptions(QueryBuilderOptions $options)
54
    {
55
        $this->queryBuilderFactory->createQueryBuilder($this->getEntityName(), $this->entityAlias);
56
57
        $fieldMappings = $this->getClassMetadata()->fieldMappings;
58
        $this->fields = array_keys($fieldMappings);
59
60
        $this->queryBuilderFactory->setFields($this->fields ?? []);
61
        $this->queryBuilderFactory->setFilters($options->getFilters());
62
        $this->queryBuilderFactory->setOrFilters($options->getOrFilters());
63
        $this->queryBuilderFactory->setSorting($options->getSorting());
64
        $this->queryBuilderFactory->setRel($options->getRel());
65
        $this->queryBuilderFactory->setPrinting($options->getPrinting());
66
        $this->queryBuilderFactory->setSelect($options->getSelect());
67
    }
68
69
    public function getQueryBuilderFactory()
70
    {
71
        $this->initFromQueryBuilderOptions($this->queryOptions);
72
73
        return $this->queryBuilderFactory;
74
    }
75
76
    public function useResultCache($bool)
77
    {
78 1
        $this->use_result_cache = $bool;
79
    }
80 1
81
    public function setRequest(Request $request)
82
    {
83
        return $this->setQueryOptionsFromRequest($request);
84
    }
85
86
    public function setRequestWithFilter(Request $request, $filter)
87
    {
88
        return $this->setQueryOptionsFromRequestWithCustomFilter($request, $filter);
89
    }
90
91
    public function setRequestWithOrFilter(Request $request, $orFilter)
92
    {
93
        return $this->setQueryOptionsFromRequestWithCustomOrFilter($request, $orFilter);
94
    }
95
96
    public function setQueryOptions(QueryBuilderOptions $options)
97
    {
98 3
        $this->queryOptions = $options;
99
    }
100 3
101
    public function setQueryOptionsFromRequest(Request $request = null)
102 3
    {
103 3
        $requestAttributes = [];
104 3
        foreach ($request->attributes->all() as $attributeName => $attributeValue) {
105 3
            $requestAttributes[$attributeName] = $request->attributes->get(
106 3
                $attributeName,
107 3
                $attributeValue
108 3
            );
109 3
        }
110 3
111
        $filters     = $request->query->get('filtering', []);
112 3
        $orFilters   = $request->query->get('filtering_or', []);
113
        $sorting     = $request->query->get('sorting', []);
114 3
        $printing    = $request->query->get('printing', []);
115 3
        $rel         = $request->query->get('rel', '');
116
        $page        = $request->query->get('page', '');
117
        $select      = $request->query->get('select', $this->entityAlias);
118
        $pageLength  = $request->query->get('limit', 666);
0 ignored issues
show
Unused Code introduced by
The assignment to $pageLength is dead and can be removed.
Loading history...
119
        $filtering   = $request->query->get('filtering', '');
120
        $limit       = $request->query->get('limit', '');
121
122
        $filterOrCorrected = [];
123
124
        $count = 0;
125
        foreach ($orFilters as $key => $filter) {
126
            if (is_array($filter)) {
127 3
                foreach ($filter as $keyInternal => $internal) {
128 3
                    $filterOrCorrected[$keyInternal .'|' . $count] = $internal;
129 3
                    $count = $count + 1;
130 3
                }
131 3
            } else {
132 3
                $filterOrCorrected[$key] = $filter;
133 3
            }
134 3
        }
135 3
136 3
        $requestProperties = [
137
            'filtering'   => $filtering,
138
            'orFiltering' => $filterOrCorrected,
139 3
            'limit'       => $limit,
140 3
            'page'        => $page,
141 3
            'filters'     => $filters,
142
            'orFilters'   => $filterOrCorrected,
143
            'sorting'     => $sorting,
144 3
            'rel'         => $rel,
145
            'printing'    => $printing,
146 3
            'select'      => $select,
147
        ];
148
149 4
        $options = array_merge(
150
            $requestAttributes,
151 4
            $requestProperties
152
        );
153 4
154
        $this->queryOptions = QueryBuilderOptions::fromArray($options);
155
156
        return $this;
157
    }
158
159 View Code Duplication
    public function setQueryOptionsFromRequestWithCustomFilter(Request $request = null, $filter)
0 ignored issues
show
Duplication introduced by
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...
160 4
    {
161
        $filters = $request->query->get('filtering', []);
162
        $orFilters = $request->query->get('filtering_or', []);
163
        $sorting = $request->query->get('sorting', []);
164
        $printing = $request->query->get('printing', []);
165
        $rel = $request->query->get('rel', '');
166
        $page = $request->query->get('page', '');
167
        $select = $request->query->get('select', $this->entityAlias);
168
        $pageLength = $request->query->get('limit', 666);
0 ignored issues
show
Unused Code introduced by
The assignment to $pageLength is dead and can be removed.
Loading history...
169
        $filtering = $request->query->get('filtering', '');
170
        $limit = $request->query->get('limit', '');
171
172
        $filters = array_merge($filters, $filter);
173
174
        $filterOrCorrected = [];
175
176
        $count = 0;
177
        foreach ($orFilters as $key => $filter) {
178
            if (is_array($filter)) {
179
                foreach ($filter as $keyInternal => $internal) {
180
                    $filterOrCorrected[$keyInternal .'|' . $count] = $internal;
181
                    $count = $count + 1;
182
                }
183
            } else {
184
                $filterOrCorrected[$key] = $filter;
185
            }
186
        }
187
188
        $this->queryOptions = QueryBuilderOptions::fromArray([
189
            '_route' => $request->attributes->get('_route'),
190
            'customer_id' => $request->attributes->get('customer_id'),
191
            'id' => $request->attributes->get('id'),
192
            'filtering' => $filtering,
193
            'limit' => $limit,
194
            'page' => $page,
195
            'filters' => $filters,
196
            'orFilters' => $filterOrCorrected,
197
            'sorting' => $sorting,
198
            'rel' => $rel,
199
            'printing' => $printing,
200
            'select' => $select,
201
        ]);
202
203
        return $this;
204
    }
205
206 View Code Duplication
    public function setQueryOptionsFromRequestWithCustomOrFilter(Request $request = null, $orFilter)
0 ignored issues
show
Duplication introduced by
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...
207
    {
208
        $filters = $request->query->get('filtering', []);
209
        $orFilters = $request->query->get('filtering_or', []);
210
        $sorting = $request->query->get('sorting', []);
211
        $printing = $request->query->get('printing', []);
212
        $rel = $request->query->get('rel', '');
213
        $page = $request->query->get('page', '');
214
        $select = $request->query->get('select', $this->entityAlias);
215
        $pageLength = $request->query->get('limit', 666);
0 ignored issues
show
Unused Code introduced by
The assignment to $pageLength is dead and can be removed.
Loading history...
216
        $filtering = $request->query->get('filtering', '');
217
        $limit = $request->query->get('limit', '');
218 1
219
        $orFilters = array_merge($orFilters, $orFilter);
220 1
221
        $filterOrCorrected = [];
222 1
223 1
        $count = 0;
224 1
        foreach ($orFilters as $key => $filter) {
225 1
            if (is_array($filter)) {
226 1
                foreach ($filter as $keyInternal => $internal) {
227 1
                    $filterOrCorrected[$keyInternal .'|' . $count] = $internal;
228 1
                    $count = $count + 1;
229 1
                }
230 1
            } else {
231
                $filterOrCorrected[$key] = $filter;
232 1
            }
233
        }
234 1
235
        $this->queryOptions = QueryBuilderOptions::fromArray([
236 1
            '_route' => $request->attributes->get('_route'),
237 1
            'customer_id' => $request->attributes->get('customer_id'),
238
            'id' => $request->attributes->get('id'),
239
            'filtering' => $filtering,
240
            'limit' => $limit,
241
            'page' => $page,
242
            'filters' => $filters,
243
            'orFilters' => $filterOrCorrected,
244
            'sorting' => $sorting,
245
            'rel' => $rel,
246
            'printing' => $printing,
247
            'select' => $select,
248
        ]);
249 1
250 1
        return $this;
251 1
    }
252 1
253 1
    public function getRequest()
254 1
    {
255 1
        return $this->request;
256 1
    }
257 1
258 1
    public function setRouteName($route_name = '')
259 1
    {
260 1
        $this->route_name = $route_name;
261
        return $this;
262
    }
263 1
264 1
    public function findAllPaginated()
265 1
    {
266
        if (!$this->queryOptions && $this->configProvider) {
267
            $this->setRequest($this->configProvider->getRequest());
268 1
            $this->queryBuilderFactory->setConfigProvider($this->configProvider);
269
        }
270 1
271
        $this->initFromQueryBuilderOptions($this->queryOptions);
272
273 4
        $this->queryBuilderFactory->filter();
274
        $this->queryBuilderFactory->sort();
275 4
276
        return $this->paginateResults($this->queryBuilderFactory->getQueryBuilder());
277
    }
278
279
    protected function paginateResults(
280
        \Doctrine\ORM\QueryBuilder $queryBuilder
281
    ) {
282
        $limit = $this->queryOptions->get('limit', 10);
283
        $page = $this->queryOptions->get('page', 1);
284
285
286
        $pagerAdapter = new DoctrineORMAdapter($queryBuilder);
287
288
        $query = $pagerAdapter->getQuery();
289
        if(isset($this->use_result_cache) and $this->use_result_cache){
290
            $query->useResultCache(true, 600);
291
        }
292
293
        $pager = new Pagerfanta($pagerAdapter);
294
        $pager->setNormalizeOutOfRangePages(true);
295
        $pager->setMaxPerPage($limit);
296
        $pager->setCurrentPage($page);
297
298
        $pagerFactory = new PagerfantaFactory();
299
300
        $router = $this->createRouter();
301
302
        $results = $pagerFactory->createRepresentation($pager, $router);
303
304
        return $results;
305
    }
306
307
    protected function customQueryStringValues()
308
    {
309
        return [];
310
    }
311
312
    protected function createRouter()
313
    {
314
        $request = $this->getRequest();
0 ignored issues
show
Unused Code introduced by
The assignment to $request is dead and can be removed.
Loading history...
315
        $params = [];
316
317
        $list = array_merge([
318
            'filtering',
319
            'limit',
320
            'page',
321
            'sorting',
322
        ], $this->customQueryStringValues());
323
324
        foreach ($list as $itemKey => $itemValue) {
325
            $params[$itemValue] = $this->queryOptions->get($itemValue);
326
        }
327
328
        if(!isset($this->route_name)){
329
            $this->route_name = $this->queryOptions->get('_route');
330
        }
331
332
        return new Route($this->route_name, $params);
333
    }
334
335
    /** @deprecate use QueryBuilderFatory instead */
336
    public function noExistsJoin($prevEntityAlias, $currentEntityAlias)
337
    {
338
        $needle = $prevEntityAlias . "_" . $currentEntityAlias;
339
        return ! in_array($needle, $this->joins);
340
    }
341
342
    /** @deprecate use QueryBuilderFatory instead */
343
    public function storeJoin($prevEntityAlias, $currentEntityAlias)
344
    {
345
        $needle = $prevEntityAlias . "_" . $currentEntityAlias;
346
        $this->joins[$needle] = $needle;
347
    }
348
349
    /** @deprecate use QueryBuilderFatory instead */
350
    public function join($queryBuilder, $key, $val) 
0 ignored issues
show
Unused Code introduced by
The parameter $val is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

350
    public function join($queryBuilder, $key, /** @scrutinizer ignore-unused */ $val) 

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
351
    {
352
        if (strstr($key, '_embedded.')) {
353
            $embeddedFields = explode('.', $key);
354
            $numFields = count($embeddedFields);
355
356
            $prevEntityAlias = $this->entityAlias; // Stocksellouts
357
            $prevEntityName = $this->getEntityName(); // Stocksellouts
358
359
            for ($i = 1; $i < $numFields - 1; $i++) {
360
                $metadata = $this->getEntityManager()->getClassMetadata($prevEntityName);
361
362
                $currentRelation = $embeddedFields[$i];
363
364
                if ($metadata->hasAssociation($currentRelation)) {
365
366
                    $association = $metadata->getAssociationMapping($currentRelation);
367
368
                    $currentEntityAlias = $this->getEntityAlias($association['targetEntity']);
369
370
                    if ($this->noExistsJoin($prevEntityAlias, $currentRelation)) {
371
                        if ($association['isOwningSide']) {
372
                            $queryBuilder->join($association['targetEntity'], "$currentEntityAlias", "WITH", "$currentEntityAlias.id = " . "$prevEntityAlias.$currentRelation");
373
                        } else {
374
                            $mappedBy = $association['mappedBy'];
375
                            $queryBuilder->join($association['targetEntity'], "$currentEntityAlias", "WITH", "$currentEntityAlias.$mappedBy = " . "$prevEntityAlias.id");
376
                        }
377
378
                        $this->storeJoin($prevEntityAlias, $currentRelation);
379
                    }
380
                }
381
382
                $prevEntityAlias = $currentEntityAlias;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $currentEntityAlias does not seem to be defined for all execution paths leading up to this point.
Loading history...
383
                $prevEntityName = $association['targetEntity'];
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $association does not seem to be defined for all execution paths leading up to this point.
Loading history...
384
            }
385
386
            $this->setEmbeddedFields($embeddedFields);
387
            $this->setCurrentEntityAlias($currentEntityAlias);
388
        }
389
390
        return $queryBuilder;
391
    }
392
393
    protected function getCurrentEntityAlias() : string
394
    {
395
        return $this->currentEntityAlias;
396
    }
397
398
    protected function setCurrentEntityAlias(string $currentEntityAlias) 
399
    {
400
        $this->currentEntityAlias = $currentEntityAlias;
401
    }
402
403
    protected function getEmbeddedFields() : array
404
    {
405
        return $this->embeddedFields;
406
    }
407
408
    protected function setEmbeddedFields(array $embeddedFields) 
409
    {
410
        $this->embeddedFields = $embeddedFields;
411
    }    
412
413
    /** @deprecate use QueryBuilderFatory component instead */
414
    //protected function sort($queryBuilder)
415
    //{
416
        //$request = $this->getRequest();
417
        //$sorting = $request->query->get('sorting', array());
418
419
        //foreach ($this->fields as $field) {
420
            //if (isset($sorting[$field])) {
421
                //$direction = ($sorting[$field] === 'asc') ? 'asc' : 'desc';
422
                //$queryBuilder->addOrderBy($this->entityAlias.'.'.$field, $direction);
423
            //}
424
        //}
425
426
        //// &sorting[_embedded.{{relazione}}.{{campo}}={{val}}
427
        //foreach ($sorting as $sort => $val) {
428
            //if (strstr($sort, '_embedded.')) {
429
430
                //$queryBuilder = $this->join($queryBuilder, $sort, $val);
431
432 1
                //$currentEntityAlias = $this->getCurrentEntityAlias();
433
                //$embeddedFields = $this->getEmbeddedFields();
434 1
                //$numFields = count($embeddedFields);
435 1
436 1
                //$fieldName = $embeddedFields[$numFields - 1];
437
                //$direction = ($val === 'asc') ? 'asc' : 'desc';
438
                //$queryBuilder->addOrderBy("$currentEntityAlias." . $fieldName, $direction);
439
            //}
440
        //}
441
442
        //return $queryBuilder;
443
    //}
444
445
    public function getEntityAlias(string $entityName) : string
446
    {
447
        $arrayEntityName = explode('\\', strtolower($entityName) );
448
        $entityAlias = $arrayEntityName[count($arrayEntityName)-1];
449
        return $entityAlias;
450
    }
451
452
    /** @deprecate use QueryBuilderFatory component instead */
453
    //protected function filter($queryBuilder)
454
    //{
455
        //$request = $this->getRequest();
456
        //$filtering = $request->query->get('filtering', array());
457
458
        //foreach ($this->fields as $field) {
459
            //if (isset($filtering[$field])) {
460
                //switch ($field) {
461
                //case 'id':
462
                //case 'year':
463
                //case 'week':                        
464
                    //$queryBuilder->andWhere($this->entityAlias.'.'.$field.' = :filter_'.$field)
465
                        //->setParameter('filter_'.$field, $filtering[$field]);                        
466
                    //break;
467
                //default:
468
                    //$queryBuilder->andWhere($this->entityAlias.'.'.$field.' LIKE :filter_'.$field)
469
                        //->setParameter('filter_'.$field, '%'.$filtering[$field].'%');
470
                //}
471
            //}
472
        //}
473
474
        //// &filtering[_embedded.{{relazione}}.{{campo}}]={{val}}
475
        //foreach ($filtering as $filter => $val) {
476
            //if (strstr($filter, '_embedded.')) {
477
478
                //$queryBuilder = $this->join($queryBuilder, $filter, $val);
479
480
                //$currentEntityAlias = $this->getCurrentEntityAlias();
481
                //$embeddedFields = $this->getEmbeddedFields();
482
                //$numFields = count($embeddedFields);
483
                //$fieldName = $embeddedFields[$numFields - 1];
484
485
                //$paramName = str_replace(".", "_", $filter);
486
487
                //switch ($fieldName) {
488
                //case 'id':
489
                //case 'codiceClienteFornitore':
490
                //case 'codiceFamily':
491
                //case 'year':
492
                //case 'week':
493
                    //$queryBuilder->andWhere("$currentEntityAlias." . $fieldName . ' = :filter_' . $paramName)
494
                        //->setParameter('filter_' . $paramName, $val);
495
                    //break;
496
                //default :
497
                    //$queryBuilder->andWhere("$currentEntityAlias." . $fieldName . ' LIKE :filter_' . $paramName)
498
                        //->setParameter('filter_' . $paramName, '%' . $val . '%');                        
499
                //}
500
            //}
501
        //}
502
503
        //return $queryBuilder;
504
    //}
505
506
    protected function relationship($queryBuilder)
507
    {
508
        return $queryBuilder;
509
    }
510
511
    /**
512
     *
513
     * @param type $insertFields
0 ignored issues
show
Bug introduced by
The type Mado\QueryBundle\Repositories\type was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
514
     * @param type $updateFields
515
     *
516
     * USE:
517
     *
518
     * $this->getEntityManager()
519
     *      ->getRepository('User')
520
     *      ->onDuplicateUpdate(['column1' => 'user_reminder_1', 'column2' => 235], ['column2' => 255]);
521
     */
522
    public function onDuplicateUpdate($insertFields, $updateFields)
523
    {
524
        //---CHIAVI
525
        $array_keys = array_keys($insertFields);
0 ignored issues
show
Bug introduced by
$insertFields of type Mado\QueryBundle\Repositories\type is incompatible with the type array expected by parameter $input of array_keys(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

525
        $array_keys = array_keys(/** @scrutinizer ignore-type */ $insertFields);
Loading history...
526
        $list_keys = '`' . implode('`,`', $array_keys) . '`';
527
528
        //---VALORI
529
        $list_values = "'" . implode("', '", $insertFields) . "'";
0 ignored issues
show
Bug introduced by
$insertFields of type Mado\QueryBundle\Repositories\type is incompatible with the type array expected by parameter $pieces of implode(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

529
        $list_values = "'" . implode("', '", /** @scrutinizer ignore-type */ $insertFields) . "'";
Loading history...
530
531
        $table = $this->getEntityManager()->getClassMetadata($this->getEntityName())->getTableName();
532
533
        $sql = 'INSERT INTO '.$table;
534
        $sql .= '('. $list_keys . ') ';
535
        //$sql .= 'VALUES("'.implode('","', $insertFields).'") ';
536
        $sql .= "VALUES(". $list_values.") ";
537
        $sql .= 'ON DUPLICATE KEY UPDATE ';
538
539
        $c = 0;
540
        foreach($updateFields as $column => $value) {
541
            if($c>0)$sql .= ", ";
542
            $sql .= '`'.$column . "` = '". $value."'";
543
            $c++;
544
        }
545
546
        $stmt = $this->getEntityManager()->getConnection()->prepare($sql);
547
        $stmt->execute();
548
    }
549
550
    public function getQueryBuilderFactoryWithoutInitialization()
551
    {
552
        return $this->queryBuilderFactory;
553
    }
554
555
    public function setConfigProvider(ConfigProvider $provider)
556
    {
557
        $this->configProvider = $provider;
558
559
        return $this;
560
    }
561
}
562