Custom::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 2 Features 1
Metric Value
c 5
b 2
f 1
dl 0
loc 10
rs 9.4286
cc 3
eloc 7
nc 3
nop 2
1
<?php
2
namespace Cassandra\Type;
3
4
class Custom extends Base{
5
    
6
    /**
7
     * 
8
     * @param string $value
9
     * @param array $definition
10
     * @throws Exception
11
     */
12
    public function __construct($value, array $definition){
13
        if ($value === null)
14
            return;
15
        $this->_definition = $definition;
16
        
17
        if (!is_string($value))
18
            throw new Exception('Incoming value must be type of string.');
19
    
20
        $this->_value = $value;
21
    }
22
    
23
    public static function binary($value, array $definition){
0 ignored issues
show
Unused Code introduced by
The parameter $definition is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
24
        return pack('n', strlen($value)) . $value;
25
    }
26
    
27
    public static function parse($binary, array $definition){
0 ignored issues
show
Unused Code introduced by
The parameter $definition is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
        $length = unpack('n', substr($binary, 0, 2))[1];
29
        return substr($binary, 2, $length);
30
    }
31
}
32