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   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 43
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toFields() 0 17 1
A fromFields() 0 16 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