Code Duplication    Length = 23-28 lines in 2 locations

src/Type/Double.php 1 location

@@ 4-31 (lines=28) @@
1
<?php
2
namespace Cassandra\Type;
3
4
class Double extends Base{
5
6
    /**
7
     * @param double $value
8
     * @throws Exception
9
     */
10
    public function __construct($value = null){
11
        if ($value === null)
12
            return;
13
        
14
        if (!is_double($value))
15
            throw new Exception('Incoming value must be type of double.');
16
    
17
        $this->_value = $value;
18
    }
19
    
20
    public static function binary($value){
21
        return strrev(pack('d', $value));
22
    }
23
    
24
    /**
25
     * @param string $binary
26
     * @return int
27
     */
28
    public static function parse($binary){
29
        return unpack('d', strrev($binary))[1];
30
    }
31
}
32

src/Type/PhpFloat.php 1 location

@@ 4-26 (lines=23) @@
1
<?php
2
namespace Cassandra\Type;
3
4
class PhpFloat extends Base{
5
    /**
6
     * @param double $value
7
     * @throws Exception
8
     */
9
    public function __construct($value = null){
10
        if ($value === null)
11
            return;
12
        
13
        if (!is_double($value))
14
            throw new Exception('Incoming value must be type of double.');
15
    
16
        $this->_value = $value;
17
    }
18
    
19
    public static function binary($value){
20
        return strrev(pack('f', $value));
21
    }
22
    
23
    public static function parse($binary){
24
        return unpack('f', strrev($binary))[1];
25
    }
26
}
27