LongValue   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 3
dl 22
loc 22
ccs 4
cts 4
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A encode() 4 4 1
A decode() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace ButterAMQP\Value;
4
5
use ButterAMQP\Binary;
6
use ButterAMQP\Buffer;
7
8 View Code Duplication
class LongValue extends AbstractValue
9
{
10
    /**
11
     * @param int $value
12
     *
13
     * @return string
14
     */
15 27
    public static function encode($value)
16
    {
17 27
        return Binary::packbe('l', $value);
18
    }
19
20
    /**
21
     * @param Buffer $data
22
     *
23
     * @return int
24
     */
25 27
    public static function decode(Buffer $data)
26
    {
27 27
        return Binary::unpackbe('l', $data->read(4));
28
    }
29
}
30