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.
Completed
Push — master ( 339665...0b0f67 )
by Carlos
02:26
created

FileToMemoryDictLoader   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 26.32 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 10
loc 38
ccs 14
cts 14
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 10 10 3
A map() 0 7 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
/*
4
 * This file is part of the overtrue/pinyin.
5
 *
6
 * (c) 2016 overtrue <[email protected]>
7
 */
8
9
namespace Overtrue\Pinyin;
10
11
use Closure;
12
13
/**
14
 * Dict File loader.
15
 */
16
class FileToMemoryDictLoader extends FileDictLoader implements DictLoaderInterface
17
{
18
    /**
19
     * Segment files
20
     *
21
     * @var array
22
     */
23
    protected $segments = array();
24
25
    /**
26
     * Constructor.
27
     *
28
     * @param string $path
29
     */
30 9 View Code Duplication
    public function __construct($path)
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...
31
    {
32 9
        parent::__construct($path);
33 9
        for ($i = 0; $i < 100; ++$i) {
34 9
            $segment = $this->path . '/' . sprintf($this->segmentName, $i);
35 9
            if (file_exists($segment)) {
36 9
                $this->segments[] = (array) include $segment;
37 9
            }
38 9
        }
39 9
    }
40
41
    /**
42
     * Load dict.
43
     *
44
     * @param Closure $callback
45
     */
46 9
    public function map(Closure $callback)
47
    {
48 9
        foreach ($this->segments as $dictionary) {
49 9
            $callback($dictionary);
50 9
        }
51
52 9
    }
53
}
54