Completed
Pull Request — master (#20)
by Haralan
18:05 queued 16:21
created

Exception::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.864

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 2
cts 5
cp 0.4
rs 9.6666
cc 2
eloc 4
nc 2
nop 3
crap 2.864
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
			$message = strtr($message, $variables);
20
		}
21
22
		parent::__construct($message, 0, $previous);
23
	}
24
}
25