GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — develop ( 404db9...8cc0dc )
by Baptiste
03:06 queued 15s
created

Methods::all()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 56
Code Lines 54

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 55
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 54
nc 1
nop 0
dl 0
loc 56
ccs 55
cts 55
cp 1
crap 1
rs 9.0036
c 0
b 0
f 0

How to fix   Long Method   

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
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Transport\Protocol\v091;
5
6
use Innmind\AMQP\Transport\Frame\Method;
7
use Innmind\Immutable\{
8
    MapInterface,
9
    Map,
10
};
11
12
final class Methods
13
{
14
    private static $all;
15
    private static $classes;
16
17 200
    public static function get(string $method): Method
18
    {
19 200
        return self::all()->get($method);
20
    }
21
22
    public static function class(Method $method): string
23
    {
24
        return self::classes()->get($method->class());
25
    }
26
27 26
    public static function classId(string $class): int
28
    {
29 26
        return self::classes()
30
            ->filter(static function(int $id, string $name) use ($class): bool {
31 26
                return $name === $class;
32 26
            })
33 26
            ->key();
34
    }
35
36
    /**
37
     * @return MapInterface<string, Method>
38
     */
39 200
    public static function all(): MapInterface
40
    {
41 200
        return self::$all ?? self::$all = Map::of('string', Method::class)
42 1
            ('connection.start', new Method(10, 10))
43 1
            ('connection.start-ok', new Method(10, 11))
44 1
            ('connection.secure', new Method(10, 20))
45 1
            ('connection.secure-ok', new Method(10, 21))
46 1
            ('connection.tune', new Method(10, 30))
47 1
            ('connection.tune-ok', new Method(10, 31))
48 1
            ('connection.open', new Method(10, 40))
49 1
            ('connection.open-ok', new Method(10, 41))
50 1
            ('connection.close', new Method(10, 50))
51 1
            ('connection.close-ok', new Method(10, 51))
52 1
            ('channel.open', new Method(20, 10))
53 1
            ('channel.open-ok', new Method(20, 11))
54 1
            ('channel.flow', new Method(20, 20))
55 1
            ('channel.flow-ok', new Method(20, 21))
56 1
            ('channel.close', new Method(20, 40))
57 1
            ('channel.close-ok', new Method(20, 41))
58 1
            ('exchange.declare', new Method(40, 10))
59 1
            ('exchange.declare-ok', new Method(40, 11))
60 1
            ('exchange.delete', new Method(40, 20))
61 1
            ('exchange.delete-ok', new Method(40, 21))
62 1
            ('queue.declare', new Method(50, 10))
63 1
            ('queue.declare-ok', new Method(50, 11))
64 1
            ('queue.bind', new Method(50, 20))
65 1
            ('queue.bind-ok', new Method(50, 21))
66 1
            ('queue.unbind', new Method(50, 50))
67 1
            ('queue.unbind-ok', new Method(50, 51))
68 1
            ('queue.purge', new Method(50, 30))
69 1
            ('queue.purge-ok', new Method(50, 31))
70 1
            ('queue.delete', new Method(50, 40))
71 1
            ('queue.delete-ok', new Method(50, 41))
72 1
            ('basic.qos', new Method(60, 10))
73 1
            ('basic.qos-ok', new Method(60, 11))
74 1
            ('basic.consume', new Method(60, 20))
75 1
            ('basic.consume-ok', new Method(60, 21))
76 1
            ('basic.cancel', new Method(60, 30))
77 1
            ('basic.cancel-ok', new Method(60, 31))
78 1
            ('basic.publish', new Method(60, 40))
79 1
            ('basic.return', new Method(60, 50))
80 1
            ('basic.deliver', new Method(60, 60))
81 1
            ('basic.get', new Method(60, 70))
82 1
            ('basic.get-ok', new Method(60, 71))
83 1
            ('basic.get-empty', new Method(60, 72))
84 1
            ('basic.ack', new Method(60, 80))
85 1
            ('basic.reject', new Method(60, 90))
86 1
            ('basic.recover-async', new Method(60, 100))
87 1
            ('basic.recover', new Method(60, 110))
88 1
            ('basic.recover-ok', new Method(60, 111))
89 1
            ('tx.select', new Method(90, 10))
90 1
            ('tx.select-ok', new Method(90, 11))
91 1
            ('tx.commit', new Method(90, 20))
92 1
            ('tx.commit-ok', new Method(90, 21))
93 1
            ('tx.rollback', new Method(90, 30))
94 200
            ('tx.rollback-ok', new Method(90, 31));
95
    }
96
97
    /**
98
     * @return MapInterface<int, string>
99
     */
100 84
    public static function classes(): MapInterface
101
    {
102 84
        return self::$classes ?? self::$classes = Map::of('int', 'string')
103 1
            (10, 'connection')
104 1
            (20, 'channel')
105 1
            (40, 'exchange')
106 1
            (50, 'queue')
107 1
            (60, 'basic')
108 84
            (90, 'tx');
109
    }
110
}
111