Custom   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 7
Bugs 3 Features 2
Metric Value
wmc 5
c 7
b 3
f 2
lcom 0
cbo 2
dl 0
loc 28
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A binary() 0 3 1
A parse() 0 4 1
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