Intraface_DBQuery   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 10
c 0
b 0
f 0
ccs 6
cts 8
cp 0.75
wmc 3
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 3
1
<?php
2
/**
3
 * Extends Ilib_DBQuery class to customize it to Intraface
4
 *
5
 * @author Sune Jensen <[email protected]>
6
 */
7
class Intraface_DBQuery extends Ilib_DBQuery
8
{
9
    /**
10
     * Constructor
11
     *
12
     * @param object $kernel
13
     * @param string $table
14
     * @param string $required_conditions
15
     *
16
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
17
     */
18 67
    public function __construct($kernel, $table, $required_conditions = "")
19
    {
20 67
        parent::__construct($table, $required_conditions);
21 67
        $session_id = $kernel->getSessionId();
22 67
        $this->createStore(md5($session_id), 'intranet_id = '.$kernel->intranet->get('id'));
23 67
        if (is_object($kernel->user) and strtolower(get_class($kernel->user)) == 'intraface_user') {
0 ignored issues
show
Comprehensibility Best Practice introduced by
Using logical operators such as and instead of && is generally not recommended.

PHP has two types of connecting operators (logical operators, and boolean operators):

  Logical Operators Boolean Operator
AND - meaning and &&
OR - meaning or ||

The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like &&, or ||.

Let’s take a look at a few examples:

// Logical operators have lower precedence:
$f = false or true;

// is executed like this:
($f = false) or true;


// Boolean operators have higher precedence:
$f = false || true;

// is executed like this:
$f = (false || true);

Logical Operators are used for Control-Flow

One case where you explicitly want to use logical operators is for control-flow such as this:

$x === 5
    or die('$x must be 5.');

// Instead of
if ($x !== 5) {
    die('$x must be 5.');
}

Since die introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined with throw at this point:

// The following is currently a parse error.
$x === 5
    or throw new RuntimeException('$x must be 5.');

These limitations lead to logical operators rarely being of use in current PHP code.

Loading history...
24
            $this->setRowsPerPage($kernel->setting->get('user', 'rows_pr_page'));
25
        }
26 67
    }
27
}
28