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.

ReorderedString::fromFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 11
cts 11
cp 1
rs 9.7333
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace MysqlUuid\Formats;
4
5
/**
6
 * A 'standard' UUID that has had the node and time_mid/time_low fields swapped
7
 *
8
 * To retain the 4,2,2,2,6 byte separators, we have to split the node field when
9
 * we move it, and combine the time_mid and time_low fields.
10
 */
11
class ReorderedString extends PlainString
12
{
13
    /**
14
     * @inheritDoc
15
     */
16 1
    public function toFields($value)
17
    {
18 1
        $fields = parent::toFields($value);
19
20
        // Node identifier is split into time_low and time_mid
21 1
        $node = $fields['time_low'] . $fields['time_mid'];
22
23
        // Time mid and low are multiplexed into node
24 1
        $time_mid = substr($fields['node'], 0, 4);
25 1
        $time_low = substr($fields['node'], 4, 8);
26
27 1
        $fields['node']     = $node;
28 1
        $fields['time_low'] = $time_low;
29 1
        $fields['time_mid'] = $time_mid;
30
31 1
        return $fields;
32
    }
33
34
    /**
35
     * @inheritDoc
36
     */
37 1
    public function fromFields(array $fields)
38
    {
39 1
        $node_high = substr($fields['node'], 0, 8);
40 1
        $node_low  = substr($fields['node'], 8, 4);
41
42 1
        $time_midlow = $fields['time_mid'] . $fields['time_low'];
43
44 1
        return sprintf(
45 1
            '%s-%s-%s-%s-%s',
46 1
            $node_high,
47 1
            $node_low,
48 1
            $fields['time_high'],
49 1
            $fields['clock_seq'],
50
            $time_midlow
51 1
        );
52
    }
53
}
54