Passed
Branch php81_ci (1e9eda)
by Eugene
08:13
created

MessagePack::pack()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
b 0
f 0
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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;
13
14
use MessagePack\Exception\InvalidOptionException;
15
use MessagePack\Exception\PackingFailedException;
16
use MessagePack\Exception\UnpackingFailedException;
17
18
final class MessagePack
19
{
20
    /**
21
     * @codeCoverageIgnore
22
     */
23
    private function __construct()
24
    {
25
    }
26
27
    /**
28
     * @param mixed $value
29
     * @param PackOptions|int|null $options
30
     *
31
     * @throws InvalidOptionException
32
     * @throws PackingFailedException
33
     */
34 2
    public static function pack($value, $options = null) : string
35
    {
36 2
        return (new Packer($options))->pack($value);
37
    }
38
39
    /**
40
     * @param UnpackOptions|int|null $options
41
     *
42
     * @throws InvalidOptionException
43
     * @throws UnpackingFailedException
44
     *
45
     * @return mixed
46
     */
47 2
    public static function unpack(string $data, $options = null)
48
    {
49 2
        return (new BufferUnpacker($data, $options))->unpack();
50
    }
51
}
52