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.

PlainString   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 25 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 11
loc 44
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
 * The traditional UUID string format
7
 */
8
class PlainString implements Format
9
{
10
    const FORMAT = '/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i';
11
12
    /**
13
     * Whether the given value appears to fit this format
14
     *
15
     * @param string $value
16
     * @return boolean
17
     */
18 4
    public function isValid($value)
19
    {
20 4
        return (boolean)preg_match(self::FORMAT, $value);
21
    }
22
23
    /**
24
     * Converts a formatted value to a set of fields
25
     *
26
     * @param string $value
27
     * @return array<string,string>
28
     */
29 5
    public function toFields($value)
30
    {
31 5
        return array_combine(['time_low', 'time_mid', 'time_high', 'clock_seq', 'node'], explode('-', $value));
32
    }
33
34
    /**
35
     * Converts a set of fields to a formatted value
36
     *
37
     * @param array <string,string> $fields
38
     * @return string
39
     */
40 2 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...
41
    {
42 2
        return sprintf(
43 2
            '%s-%s-%s-%s-%s',
44 2
            $fields['time_low'],
45 2
            $fields['time_mid'],
46 2
            $fields['time_high'],
47 2
            $fields['clock_seq'],
48 2
            $fields['node']
49 2
        );
50
    }
51
}
52