BinaryDataParser::parse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * This file is part of graze/unicontroller-client.
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/unicontroller-client/blob/master/LICENSE.md
11
 * @link https://github.com/graze/unicontroller-client
12
 */
13
namespace Graze\UnicontrollerClient\Parser;
14
15
use Graze\UnicontrollerClient\Parser\Parser\ParserInterface;
16
17
class BinaryDataParser
18
{
19
    /**
20
     * @param string $string
21
     * @return string
22
     */
23 3
    public function parse($string)
24
    {
25 3
        list(, $length, $binaryData) = explode(',', $string, 3);
26 3
        $binaryData = substr($binaryData, 0, -10); // remove 'BinaryEnd,'
27 3
        return trim($binaryData, "\r\n");
28
    }
29
}
30