Passed
Push — master ( 745178...3deda8 )
by Alexey
03:44
created

AbstractRepository   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A quote() 0 8 4
A __construct() 0 5 1
1
<?php
2
/**
3
 * This file is part of the wow-apps/symfony-proxybonanza project
4
 * https://github.com/wow-apps/symfony-proxybonanza
5
 *
6
 * (c) 2016 WoW-Apps
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WowApps\ProxybonanzaBundle\Repository;
13
14
use Doctrine\DBAL\Driver\PDOConnection;
15
use Doctrine\ORM\EntityManager;
16
use Doctrine\ORM\EntityRepository;
17
use Doctrine\ORM\Mapping;
18
19
/**
20
 * Class AbstractRepository
21
 * @author Alexey Samara <[email protected]>
22
 * @package wow-apps/symfony-proxybonanza
23
 */
24
abstract class AbstractRepository extends EntityRepository
25
{
26
    /** @var PDOConnection */
27
    protected $pdoDB;
28
29
    /** @var EntityManager */
30
    protected $entityManager;
31
32
    /**
33
     * AbstractRepository constructor.
34
     * @param EntityManager $entityManager
35
     * @param Mapping\ClassMetadata $class
36
     */
37
    public function __construct(EntityManager $entityManager, Mapping\ClassMetadata $class)
38
    {
39
        parent::__construct($entityManager, $class);
40
        $this->entityManager = $entityManager;
41
        $this->pdoDB = $entityManager->getConnection();
0 ignored issues
show
Documentation Bug introduced by
It seems like $entityManager->getConnection() of type Doctrine\DBAL\Connection is incompatible with the declared type Doctrine\DBAL\Driver\PDOConnection of property $pdoDB.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
42
    }
43
44
    /**
45
     * @param string $value
46
     * @return string
47
     */
48
    protected function quote(string $value): string
49
    {
50
        $emptyValues = ['%', '%%', '_'];
51
        if (($value === 0) || (!empty($value) && !in_array($value, $emptyValues))) {
52
            return $this->pdoDB->quote($value);
53
        }
54
55
        return 'NULL';
56
    }
57
}
58