Passed
Push — master ( c2b86a...ea64e0 )
by Andrea
10:32
created

TabelleSingletonUtility::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 3
crap 6
1
<?php
2
3
/*
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
9
namespace Fi\CoreBundle\Utils;
10
11
final class TabelleSingletonUtility
12
{
13
14
    private static $queryTabelle;
15
16
    /**
17
     * Call this method to get singleton
18
     *
19
     * @return UserFactory
0 ignored issues
show
Bug introduced by
The type Fi\CoreBundle\Utils\UserFactory 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...
20
     */
21 17
    public static function instance($em, $nometabella, $operatore)
22
    {
23 17
        static $inst = null;
24 17
        if ($inst === null) {
25
            $inst = new TabelleSingletonUtility($em, $nometabella, $operatore);
26
        }
27 17
        return $inst;
28
    }
29
30
    /**
31
     * Private construct so nobody else can instantiate it
32
     *
33
     */
34
    private function __construct($em, $nometabella, $operatore)
35
    {
36
        self::$queryTabelle = $em->getRepository('FiCoreBundle:Tabelle')->findBy(array('operatori_id' => $operatore, 'nometabella' => $nometabella));
37
38
        if (!self::$queryTabelle) {
39
            self::$queryTabelle = $em->getRepository('FiCoreBundle:Tabelle')->findBy(array('operatori_id' => null, 'nometabella' => $nometabella));
40
        }
41
    }
42
43 17
    public static function getTabelle()
44
    {
45 17
        return self::$queryTabelle;
46
    }
47
}
48