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

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 24.44 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 11
loc 45
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 4 1
A toFields() 0 4 1
A fromFields() 11 11 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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