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.

Hex::fromFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
dl 11
loc 11
ccs 9
cts 9
cp 1
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace MysqlUuid\Formats;
4
5
/**
6
 * Hex with dashes removed, a 32 byte string of hex characters
7
 */
8
class Hex implements Format
9
{
10
    /**
11
     * Whether the given value appears to fit this format
12
     *
13
     * @param string $value
14
     * @return boolean
15
     */
16 1
    public function isValid($value)
17
    {
18 1
        return (boolean)preg_match('/[0-9A-F]{32}/i', $value);
19
    }
20
21
    /**
22
     * Converts a formatted value to a set of fields
23
     *
24
     * @param string $value
25
     * @return array<string,string>
26
     */
27 1
    public function toFields($value)
28
    {
29
        return [
30 1
            'time_low'  => substr($value, 0, 8),
31 1
            'time_mid'  => substr($value, 8, 4),
32 1
            'time_high' => substr($value, 12, 4),
33 1
            'clock_seq' => substr($value, 16, 4),
34 1
            'node'      => substr($value, 20, 12)
35 1
        ];
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 sprintf(
47 1
            '%s%s%s%s%s',
48 1
            $fields['time_low'],
49 1
            $fields['time_mid'],
50 1
            $fields['time_high'],
51 1
            $fields['clock_seq'],
52 1
            $fields['node']
53 1
        );
54
    }
55
}
56