ShortStringValue::encode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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