Completed
Push — master ( 0f75be...b86c40 )
by Eugene
08:39 queued 07:16
created

PackerFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 3
cts 6
cp 0.5
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 12 3
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
use Tarantool\Client\Packer\Packer as ClientPacker;
18
19
final class PackerFactory
20
{
21 14
    public static function create() : ClientPacker
22
    {
23 14
        if (\class_exists(BufferUnpacker::class)) {
24 14
            return PurePacker::fromAvailableExtensions();
25
        }
26
27
        if (\extension_loaded('msgpack')) {
28
            return new PeclPacker();
29
        }
30
31
        throw new \Error('None of the supported msgpack packages were found. To install one, run "composer require rybakit/msgpack"');
0 ignored issues
show
Unused Code introduced by
The call to Error::__construct() has too many arguments starting with 'None of the supported m...quire rybakit/msgpack"'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
32
    }
33
}
34