Completed
Push — master ( 092247...6dd5e4 )
by Stéphane
06:20 queued 03:28
created

ExceptionFactory::build()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.4326

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
ccs 7
cts 11
cp 0.6364
rs 9.4285
cc 3
eloc 13
nc 3
nop 2
crap 3.4326
1
<?php
2
/**
3
 * This file is part of the bee4/transport package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 *
7
 * @copyright Bee4 2015
8
 * @author  Stephane HULARD <[email protected]>
9
 * @package Bee4\Transport\Exception\Curl
10
 */
11
12
namespace Bee4\Transport\Exception\Curl;
13
14
use Bee4\Transport\Exception\CurlException;
15
16
/**
17
 * Error thrown when the URL is considered malformed by cURL
18
 * @package Bee4\Transport\Exception\Curl
19
 */
20
class ExceptionFactory
21
{
22 2
    public static function build($code, $message)
23
    {
24 2
        $error = null;
0 ignored issues
show
Unused Code introduced by
$error is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
25
        switch ($code) {
26 2
            case CURLE_UNSUPPORTED_PROTOCOL:
27
                $error = new UnsupportedProtocolException($message, $code);
28
                break;
29 2
            case CURLE_URL_MALFORMAT:
30
                $error = new MalformedUrlException($message, $code);
31
                break;
32
            default:
33 2
                $error = new CurlException($message, $code);
34 2
                break;
35
        }
36 2
        return $error;
37
    }
38
}
39