QueryException::create()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 11
ccs 0
cts 10
cp 0
rs 9.4285
cc 2
eloc 7
nc 2
nop 2
crap 6
1
<?php
2
3
namespace Thruster\Component\MysqlClient\Exception;
4
5
use Exception;
6
7
/**
8
 * Class QueryException
9
 *
10
 * @package Thruster\Component\MysqlClient\Exception
11
 * @author  Aurimas Niekis <[email protected]>
12
 */
13
class QueryException extends Exception
14
{
15
    public static function create(string $message, int $code)
16
    {
17
        switch ($code) {
18
            case 1062:
19
                return new RecordDuplicateException($message);
20
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
21
22
            default:
23
                return new static($message, $code);
24
        }
25
    }
26
}
27