ChronopostCodesTransformer::getStateFromCode()   C
last analyzed

Complexity

Conditions 11
Paths 11

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 132

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 23
ccs 0
cts 18
cp 0
rs 5.3929
cc 11
eloc 18
nc 11
nop 1
crap 132

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
namespace LWI\DeliveryTracking\Behavior;
4
5
use LWI\DeliveryTracking\DeliveryStatus;
6
7
trait ChronopostCodesTransformer
8
{
9
    /**
10
     * @param string $code
11
     *
12
     * @return null | DeliveryStatus
13
     */
14
    protected function getStateFromCode($code)
15
    {
16
        switch ($code) {
17
            case 'D':
18
            case 'D1':
19
            case 'D2':
20
            case 'RG':
21
            case 'DD':
22
            case 'B':
23
            case 'U':
24
            case 'VC':
25
            case 'RI':
26
            case 'RR':
27
                $state = DeliveryStatus::stateDelivered();
28
                break;
29
30
            default:
31
                $state = DeliveryStatus::stateInProgress();
32
                break;
33
        }
34
35
        return $state;
36
    }
37
}
38