SignedCharStringSerializer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A serialize() 0 3 1
A deserialize() 0 3 1
1
<?php
2
3
/**
4
 * Copyright 2017 American Express Travel Related Services Company, Inc.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
15
 * or implied. See the License for the specific language governing
16
 * permissions and limitations under the License.
17
 */
18
19
declare(strict_types=1);
20
21
namespace AmericanExpress\HyperledgerFabricClient\Serializer;
22
23
final class SignedCharStringSerializer implements StringSerializerInterface
24
{
25
    /**
26
     * @param array $array
27
     * @return string
28
     */
29 1
    public function serialize(array $array): string
30
    {
31 1
        return pack(...array_merge(['c*'], $array));
0 ignored issues
show
Bug introduced by
array_merge(array('c*'), $array) is expanded, but the parameter $format of pack() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
        return pack(/** @scrutinizer ignore-type */ ...array_merge(['c*'], $array));
Loading history...
32
    }
33
34
    /**
35
     * @param string $data
36
     * @return array
37
     */
38 1
    public function deserialize(string $data): array
39
    {
40 1
        return \unpack('c*', $data);
0 ignored issues
show
Bug introduced by
The call to unpack() has too few arguments starting with offset. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
        return /** @scrutinizer ignore-call */ \unpack('c*', $data);

This check compares calls to functions or methods with their respective definitions. If the call has less 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. Please note the @ignore annotation hint above.

Loading history...
41
    }
42
}
43