BiCoreSystemTablesUtils::getSystemEntities()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Cdf\BiCoreBundle\Utils\Entity;
4
5
use Cdf\BiCoreBundle\Entity\Ruoli;
6
use Doctrine\ORM\EntityManager;
7
8
class BiCoreSystemTablesUtils
9
{
10
    /* @var $em EntityManager */
0 ignored issues
show
Documentation Bug introduced by
The doc comment $em at position 0 could not be parsed: Unknown type name '$em' at position 0 in $em.
Loading history...
11
12
    private EntityManager $em;
13
14
    /**
15
     *
16
     * @var array<mixed>
17
     */
18
    private $entities = array();
19
20 2
    public function __construct(EntityManager $em)
21
    {
22 2
        $this->em = $em;
23 2
        $this->entities[Ruoli::class] = array('priority' => 10);
24 2
        $this->entities["Cdf\BiCoreBundle\Entity\Operatori"] = array('priority' => 50);
25 2
        $this->entities["Cdf\BiCoreBundle\Entity\Permessi"] = array('priority' => 100);
26 2
        $this->entities["Cdf\BiCoreBundle\Entity\Storicomodifiche"] = array('priority' => 110);
27 2
        $this->entities["Cdf\BiCoreBundle\Entity\Colonnetabelle"] = array('priority' => 120);
28 2
        $this->entities["Cdf\BiCoreBundle\Entity\Opzionitabelle"] = array('priority' => 150);
29 2
        $this->entities["Cdf\BiCoreBundle\Entity\Menuapplicazione"] = array('priority' => 160);
30
31 2
        $this->countEntitiesRows();
32
    }
33
34
    /**
35
     * @SuppressWarnings(PHPMD.UnusedLocalVariable)
36
     */
37 2
    public function countEntitiesRows(): void
38
    {
39 2
        $records = $this->entities;
40 2
        foreach ($records as $entity => $detail) {
41 2
            $qb = $this->em;
42 2
            $numrows = $qb->createQueryBuilder()
43 2
                    ->select('count(table.id)')
44 2
                    ->from($entity, 'table')
45 2
                    ->getQuery()
46 2
                    ->getSingleScalarResult();
47 2
            $this->entities[$entity]['rows'] = $numrows;
48
        }
49
    }
50
51
    /**
52
     *
53
     * @return array<mixed>
54
     */
55 2
    public function getSystemEntities(): array
56
    {
57 2
        return $this->entities;
58
    }
59
60
    /**
61
     *
62
     * @return array<mixed>
63
     */
64
    public function getDefaultDataSystemEntities(): array
65
    {
66
        return $this->entities;
67
    }
68
}
69