Passed
Push — develop ( a2d318...68c2d4 )
by Andrea
15:23
created

Tabella::getRecordstabella()   A

Complexity

Conditions 5
Paths 10

Size

Total Lines 36
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 20
CRAP Score 5.0026

Importance

Changes 0
Metric Value
cc 5
eloc 21
nc 10
nop 0
dl 0
loc 36
ccs 20
cts 21
cp 0.9524
crap 5.0026
rs 9.2728
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Tabella::getMaxOrdine() 0 3 1
A Tabella::setMaxOrdine() 0 4 2
1
<?php
2
3
namespace Cdf\BiCoreBundle\Utils\Tabella;
4
5
use Cdf\BiCoreBundle\Utils\Entity\EntityUtils;
6
7
/**
8
 * @property \Doctrine\ORM\EntityManager $em
9
 * @property \Cdf\BiCoreBundle\Utils\Permessi\PermessiUtils $permessi
10
 * @property \Symfony\Component\Security\Core\Security $user
11
 */
12
13
/**
14
 * @SuppressWarnings(PHPMD.TooManyFields)
15
 */
16
class Tabella
17
{
18
19
    use TabellaQueryTrait,
0 ignored issues
show
Bug introduced by
The trait Cdf\BiCoreBundle\Utils\Tabella\TabellaQueryTrait requires the property $reflFields which is not provided by Cdf\BiCoreBundle\Utils\Tabella\Tabella.
Loading history...
20
        TabellaOpzioniTrait,
21
        TabellaDecoderTrait;
22
23
    protected $parametri;
24
    protected $colonnedatabase;
25
    protected $opzionitabellacore;
26
    protected $configurazionecolonnetabella;
27
    protected $entityname;
28
    protected $tablename;
29
    protected $modellocolonne;
30
    protected $paginacorrente;
31
    protected $righeperpagina;
32
    protected $estraituttirecords;
33
    protected $prefiltri;
34
    protected $filtri;
35
    protected $wheremanuale;
36
    protected $colonneordinamento;
37
    protected $permessi;
38
    protected $records;
39
    protected $paginetotali;
40
    protected $righetotali;
41
    protected $traduzionefiltri;
42
    protected $maxordine = 0;
43
    protected $em;
44
    protected $user;
45
46 12
    public function __construct($doctrine, $parametri = '{}')
47
    {
48 12
        $this->parametri = $parametri;
49 12
        if (isset($this->parametri['em'])) {
50 12
            $this->em = $doctrine->getManager(ParametriTabella::getParameter($this->parametri['em']));
51
        } else {
52
            $this->em = $doctrine->getManager();
53
        }
54
55 12
        $this->tablename = $this->getTabellaParameter("tablename");
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 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...
Coding Style Comprehensibility introduced by
The string literal tablename does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
56 12
        $this->entityname = $this->getTabellaParameter("entityclass");
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 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...
Coding Style Comprehensibility introduced by
The string literal entityclass does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
57 12
        $this->entityname = str_replace("FiBiCoreBundle", "BiCoreBundle", $this->entityname);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 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...
Coding Style Comprehensibility introduced by
The string literal FiBiCoreBundle does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style Comprehensibility introduced by
The string literal BiCoreBundle does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
58 12
        $this->permessi = json_decode($this->getTabellaParameter("permessi"));
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 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...
Coding Style Comprehensibility introduced by
The string literal permessi does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
59 12
        $this->modellocolonne = json_decode($this->getTabellaParameter('modellocolonne', array()), true);
0 ignored issues
show
Bug introduced by
It seems like $this->getTabellaParamet...dellocolonne', array()) can also be of type array; however, parameter $json of json_decode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

59
        $this->modellocolonne = json_decode(/** @scrutinizer ignore-type */ $this->getTabellaParameter('modellocolonne', array()), true);
Loading history...
60 12
        $this->paginacorrente = $this->getTabellaParameter("paginacorrente");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal paginacorrente does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
61 12
        $this->paginetotali = $this->getTabellaParameter("paginetotali");
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...
Coding Style Comprehensibility introduced by
The string literal paginetotali does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
62 12
        $this->righeperpagina = $this->getTabellaParameter('righeperpagina', 15);
63
64 12
        $this->estraituttirecords = $this->getTabellaParameter('estraituttirecords', 0) === "1" ? true : false;
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal 1 does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
65 12
        $this->colonneordinamento = json_decode($this->getTabellaParameter('colonneordinamento', array()), true);
66 12
        $this->prefiltri = json_decode($this->getTabellaParameter('prefiltri', array()), true);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 10 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...
67 12
        $this->filtri = json_decode($this->getTabellaParameter('filtri', array()), true);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 13 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...
68 12
        $this->wheremanuale = $this->getTabellaParameter("wheremanuale", null);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 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...
Coding Style Comprehensibility introduced by
The string literal wheremanuale does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
69 12
        $this->user = $this->parametri["user"];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 15 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...
Coding Style Comprehensibility introduced by
The string literal user does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
70
71 12
        $utils = new EntityUtils($this->em, $this->entityname);
0 ignored issues
show
Unused Code introduced by
The call to Cdf\BiCoreBundle\Utils\E...ityUtils::__construct() has too many arguments starting with $this->entityname. ( Ignorable by Annotation )

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

71
        $utils = /** @scrutinizer ignore-call */ new EntityUtils($this->em, $this->entityname);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 30 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...
72 12
        $this->colonnedatabase = $utils->getEntityColumns($this->entityname);
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...
73 12
        $this->opzionitabellacore = $this->getOpzionitabellaFromCore();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 11 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...
74 12
        $this->configurazionecolonnetabella = $this->getAllOpzioniTabella();
75 12
    }
76 12
    private function getTabellaParameter($name, $default = null)
77
    {
78 12
        $risposta = null;
79 12
        if (isset($this->parametri[$name])) {
80 12
            $risposta = ParametriTabella::getParameter($this->parametri[$name]);
81
        } else {
82 12
            $risposta = $default;
83
        }
84 12
        return $risposta;
85
    }
86 12
    public function calcolaPagineTotali($limit)
87
    {
88 12
        if ($this->righetotali == 0) {
89 1
            return 1;
90
        }
91
        /* calcola in mumero di pagine totali necessarie */
92 12
        return ceil($this->righetotali / ($limit == 0 ? 1 : $limit));
93
    }
94
95 12
    public function getPaginacorrente()
96
    {
97 12
        return $this->paginacorrente;
98
    }
99 7
    public function getPaginetotali()
100
    {
101 7
        return $this->paginetotali;
102
    }
103 12
    public function getRigheperpagina()
104
    {
105 12
        return $this->righeperpagina;
106
    }
107 12
    public function getRighetotali()
108
    {
109 12
        return $this->righetotali;
110
    }
111 7
    public function getTraduzionefiltri()
112
    {
113 7
        return $this->traduzionefiltri;
114
    }
115 10
    public function getConfigurazionecolonnetabella()
116
    {
117 10
        return $this->configurazionecolonnetabella;
118
    }
119 12
    protected function setMaxOrdine($ordinecorrente)
120
    {
121 12
        if ($ordinecorrente > $this->maxordine) {
122 12
            $this->maxordine = $ordinecorrente;
123
        }
124 12
    }
125 12
    protected function getMaxOrdine()
126
    {
127 12
        return $this->maxordine;
128
    }
129
}
130