Completed
Push — master ( 79150a...2528a8 )
by Sergey
03:52
created

AMQPException::make()   D

Complexity

Conditions 18
Paths 18

Size

Total Lines 41
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 102.4974

Importance

Changes 0
Metric Value
dl 0
loc 41
ccs 13
cts 36
cp 0.361
rs 4.947
c 0
b 0
f 0
cc 18
eloc 37
nc 18
nop 2
crap 102.4974

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/*
3
 * This file is automatically generated.
4
 */
5
6
namespace ButterAMQP\Exception;
7
8
/**
9
 * @codeCoverageIgnore
10
 */
11
class AMQPException extends \Exception
12
{
13
    public static function make($message, $code)
14
    {
15
        if ($code === 311) {
16
            return new AMQP\ContentTooLargeException($message, $code);
17
        } elseif ($code === 313) {
18
            return new AMQP\NoConsumersException($message, $code);
19
        } elseif ($code === 320) {
20
            return new AMQP\ConnectionForcedException($message, $code);
21
        } elseif ($code === 402) {
22
            return new AMQP\InvalidPathException($message, $code);
23
        } elseif ($code === 403) {
24
            return new AMQP\AccessRefusedException($message, $code);
25
        } elseif ($code === 404) {
26
            return new AMQP\NotFoundException($message, $code);
27
        } elseif ($code === 405) {
28
            return new AMQP\ResourceLockedException($message, $code);
29
        } elseif ($code === 406) {
30
            return new AMQP\PreconditionFailedException($message, $code);
31
        } elseif ($code === 501) {
32
            return new AMQP\FrameErrorException($message, $code);
33
        } elseif ($code === 502) {
34
            return new AMQP\SyntaxErrorException($message, $code);
35
        } elseif ($code === 503) {
36
            return new AMQP\CommandInvalidException($message, $code);
37
        } elseif ($code === 504) {
38
            return new AMQP\ChannelErrorException($message, $code);
39
        } elseif ($code === 505) {
40
            return new AMQP\UnexpectedFrameException($message, $code);
41
        } elseif ($code === 506) {
42
            return new AMQP\ResourceErrorException($message, $code);
43
        } elseif ($code === 530) {
44
            return new AMQP\NotAllowedException($message, $code);
45
        } elseif ($code === 540) {
46
            return new AMQP\NotImplementedException($message, $code);
47
        } elseif ($code === 541) {
48
            return new AMQP\InternalErrorException($message, $code);
49
        } else {
50
            return new self($message, $code);
51
        }
52
    }
53
}
54