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.

Contents   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 45.45 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 10
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A read() 10 16 2

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
 * Contents.php
4
 *
5
 * @package         ProjectVersioner
6
 * @subpackage      Reader
7
 */
8
9
namespace Naneau\ProjectVersioner\Reader\Finder;
10
11
/**
12
 * Contents
13
 *
14
 * Combines contents from all found files
15
 *
16
 * @category        Naneau
17
 * @package         ProjectVersioner
18
 * @subpackage      Reader
19
 */
20
class Contents extends Finder
21
{
22
    /**
23
     * {@inheritdoc}
24
     **/
25
    public function read($directory)
26
    {
27
        $hash = '';
28 View Code Duplication
        foreach ($this->getFinder() as $file) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
29
30
            // MD5 hash of the file
31
            $fileHash = md5_file(
32
                $file->getPath() . DIRECTORY_SEPARATOR . $file->getFilename()
33
            );
34
35
            // Mix into result hash
36
            $hash = md5($hash . $fileHash);
37
        }
38
39
        return substr($hash, 0, 6);
40
    }
41
}
42