Passed
Push — master ( ec6f37...197b26 )
by Eugene
03:25
created

PackerFactory::create()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 11
ccs 5
cts 6
cp 0.8333
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 0
crap 3.0416
1
<?php
2
3
/**
4
 * This file is part of the Tarantool Client 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
declare(strict_types=1);
13
14
namespace Tarantool\Client\Packer;
15
16
use MessagePack\BufferUnpacker;
17
18
final class PackerFactory
19
{
20 2
    public static function create() : Packer
21
    {
22 2
        if (\class_exists(BufferUnpacker::class)) {
23 1
            return new PurePacker();
24
        }
25
26 1
        if (\extension_loaded('msgpack')) {
27 1
            return new PeclPacker();
28
        }
29
30
        throw new \Error('None of the supported msgpack packages were found. To install one, run "composer require rybakit/msgpack".');
31
    }
32
}
33