AuthIpsRepository::insertAuthIps()   B
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 20
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 10
nc 4
nop 1
dl 0
loc 20
rs 8.8571
c 0
b 0
f 0
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 WowApps\ProxybonanzaBundle\Entity\Plan;
15
use WowApps\ProxybonanzaBundle\Entity\AuthIps;
16
17
/**
18
 * Class AuthIpsRepository
19
 * @author Alexey Samara <[email protected]>
20
 * @package wow-apps/symfony-proxybonanza
21
 */
22
class AuthIpsRepository extends AbstractRepository
23
{
24
    public function empty()
25
    {
26
        $queryBuilder = $this->pdoDB->createQueryBuilder();
0 ignored issues
show
Bug introduced by
The method createQueryBuilder() does not exist on Doctrine\DBAL\Driver\PDOConnection. ( Ignorable by Annotation )

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

26
        /** @scrutinizer ignore-call */ 
27
        $queryBuilder = $this->pdoDB->createQueryBuilder();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
        $queryBuilder->delete(AuthIps::TABLE_NAME);
28
        $queryBuilder->execute();
29
    }
30
31
    /**
32
     * @param \ArrayObject|Plan[] $pbPlans
33
     * @return bool
34
     */
35
    public function insertAuthIps(\ArrayObject $pbPlans): bool
36
    {
37
        if (!$pbPlans->count()) {
38
            return false;
39
        }
40
41
        foreach ($pbPlans as $pbPlan) {
42
            if (!empty($pbPlan->getAuthIps())) {
43
                continue;
44
            }
45
46
            foreach ($pbPlan->getAuthIps() as $authIp) {
47
                $authIp->setPlan($pbPlan->getPlanId());
48
                $this->entityManager->persist($authIp);
49
            }
50
        }
51
52
        $this->entityManager->flush();
53
54
        return true;
55
    }
56
}
57