Exception::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
namespace Openbuildings\Spiderling;
4
5
/**
6
 * Extend exception to allow variables
7
 *
8
 * @package    Openbuildings\Spiderling
9
 * @author     Ivan Kerin
10
 * @copyright  (c) 2013 OpenBuildings Ltd.
11
 * @license    http://spdx.org/licenses/BSD-3-Clause
12
 */
13
class Exception extends \Exception {
14
15 40
	public function __construct($message, array $variables = array(), \Exception $previous = NULL)
16
	{
17 40
		if ($variables)
0 ignored issues
show
Bug Best Practice introduced by
The expression $variables of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
18
		{
19 38
			$message = strtr($message, $variables);
20
		}
21
22 40
		parent::__construct($message, 0, $previous);
23 40
	}
24
}
25