Exception::createByFormat()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 4
c 1
b 0
f 1
nc 2
nop 4
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 2
rs 9.4285
1
<?php namespace BuildR\Foundation\Exception;
2
3
use \Exception as VanillaException;
4
5
/**
6
 * Base Exception
7
 *
8
 * BuildR PHP Framework
9
 *
10
 * @author Zoltán Borsos <[email protected]>
11
 * @package Foundation
12
 * @subpackage Exception
13
 *
14
 * @copyright    Copyright 2015, Zoltán Borsos.
15
 * @license      https://github.com/Zolli/BuildR/blob/master/LICENSE.md
16
 * @link         https://github.com/Zolli/BuildR
17
 */
18
class Exception extends VanillaException{
19
20
    /**
21
     * Create a new exception with a prepared message. Message is prepared using vsptintf()
22
     * if you provide a format.
23
     *
24
     * @param string $message The exception message
25
     * @param array $format The format elements
26
     * @param int $code Exception code
27
     * @param \Exception $previous Previous exception class
28
     *
29
     * @return static
30
     */
31 3
    public static function createByFormat($message = "", $format = [], $code = 0, VanillaException $previous = NULL) {
32 3
        if(!empty($format)) {
33 1
            $message = vsprintf($message, $format);
34 1
        }
35
36 3
        return new static($message, $code, $previous);
37
    }
38
39
}
40