Passed
Push — master ( 1e250a...632266 )
by Andrea
22:07
created

TabelleSingletonUtility::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 3
crap 2
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
    private static $nometabella;
16
    private static $operatore;
17
18
    /**
19
     * Call this method to get singleton
20
     *
21
     * @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...
22
     */
23 17
    public static function instance($em, $nometabella, $operatore)
24
    {
25 17
        static $inst = null;
26 17
        if ($inst === null) {
27
            self::$nometabella = $nometabella;
28
            self::$operatore = $operatore;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
29
            $inst = new TabelleSingletonUtility($em, $nometabella, $operatore);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 14 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
30
        }
31 17
        if ($nometabella != self::$nometabella || $operatore != self::$operatore) {
32 10
            self::$nometabella = $nometabella;
33 10
            self::$operatore = $operatore;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
34 10
            $inst = new TabelleSingletonUtility($em, $nometabella, $operatore);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 14 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
35 10
        }
36 17
        return $inst;
37
    }
38
39
    /**
40
     * Private construct so nobody else can instantiate it
41
     *
42
     */
43 10
    private function __construct($em, $nometabella, $operatore)
44
    {
45 10
        self::$queryTabelle = $em->getRepository('FiCoreBundle:Tabelle')->findBy(array('operatori_id' => $operatore, 'nometabella' => $nometabella));
46
47 10
        if (!self::$queryTabelle) {
48 10
            self::$queryTabelle = $em->getRepository('FiCoreBundle:Tabelle')->findBy(array('operatori_id' => null, 'nometabella' => $nometabella));
49 10
        }
50 10
    }
51
52 17
    public static function getTabelle()
53
    {
54 17
        return self::$queryTabelle;
55
    }
56
}
57