ShortStringValue   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

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\Buffer;
6
7 View Code Duplication
class ShortStringValue extends AbstractValue
8
{
9
    /**
10
     * @param string $value
11
     *
12
     * @return string
13
     */
14 23
    public static function encode($value)
15
    {
16 23
        return pack('C', strlen($value)).$value;
17
    }
18
19
    /**
20
     * @param Buffer $data
21
     *
22
     * @return string
23
     */
24 23
    public static function decode(Buffer $data)
25
    {
26 23
        return $data->read(unpack('C', $data->read(1))[1]);
27
    }
28
}
29