Completed
Push — master ( 3615fd...6bd7ca )
by Eugene
06:46
created

Extension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 25
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getType() 0 4 1
A pack() 0 8 2
packExt() 0 1 ?
1
<?php
2
3
/*
4
 * This file is part of the rybakit/msgpack.php package.
5
 *
6
 * (c) Eugene Leonovich <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace MessagePack\TypeTransformer;
13
14
use MessagePack\Packer;
15
16
abstract class Extension implements CanPack, CanUnpackExt
17
{
18
    private $type;
19
20
    public function __construct(int $type)
21
    {
22
        $this->type = $type;
23
    }
24
25
    public function getType() : int
26
    {
27
        return $this->type;
28
    }
29
30
    public function pack(Packer $packer, $value) : ?string
31
    {
32
        if (null === $data = $this->packExt($packer, $value)) {
33
            return null;
34
        }
35
36
        return $packer->packExt($this->type, $data);
37
    }
38
39
    abstract protected function packExt(Packer $packer, $value) : ?string;
40
}
41