GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Binary::isValid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace MysqlUuid\Formats;
4
5
/**
6
 * 16 byte binary format
7
 *
8
 * The binary format always uses the same byte order: node, clock_seq, time_high, time_mid, time_low
9
 * So, we don't need to support reordering
10
 */
11
class Binary implements Format
12
{
13
    const PACK   = 'H12H4H4H4H8';
14
    const UNPACK = 'H12node/H4clock_seq/H4time_high/H4time_mid/H8time_low';
15
16
    /**
17
     * Whether the given value appears to fit this format
18
     *
19
     * @param string $value
20
     * @return boolean
21
     */
22 1
    public function isValid($value)
23
    {
24 1
        return (strlen($value) == 16);
25
    }
26
27
    /**
28
     * Converts a formatted value to a set of fields
29
     *
30
     * @param string $value
31
     * @return array<string,string>
32
     */
33 2
    public function toFields($value)
34
    {
35 2
        return unpack(self::UNPACK, $value);
36
    }
37
38
    /**
39
     * Converts a set of fields to a formatted value
40
     *
41
     * @param array <string,string> $fields
42
     * @return string
43
     */
44 1 View Code Duplication
    public function fromFields(array $fields)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
    {
46 1
        return pack(
47 1
            self::PACK,
48 1
            $fields['node'],
49 1
            $fields['clock_seq'],
50 1
            $fields['time_high'],
51 1
            $fields['time_mid'],
52 1
            $fields['time_low']
53 1
        );
54
    }
55
}
56