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 ( 5d16d0...819586 )
by Carlos
03:00
created

FileDictLoader::mapSurname()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 7
cts 7
cp 1
rs 9.6666
cc 2
eloc 5
nc 2
nop 1
crap 2
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 FileDictLoader implements DictLoaderInterface
17
{
18
    /**
19
     * Words segment name.
20
     *
21
     * @var string
22
     */
23
    protected $segmentName = 'words_%s';
24
25
    /**
26
     * Dict path.
27
     *
28
     * @var string
29
     */
30
    protected $path;
31
32
    /**
33
     * Constructor.
34
     *
35
     * @param string $path
36
     */
37 9
    public function __construct($path)
38
    {
39 9
        $this->path = $path;
40 9
    }
41
42
    /**
43
     * Load dict.
44
     *
45
     * @param Closure $callback
46
     */
47 9
    public function map(Closure $callback)
48
    {
49 9
        for ($i = 0; $i < 100; ++$i) {
50 9
            $segment = $this->path.'/'.sprintf($this->segmentName, $i);
51
52 9
            if (file_exists($segment)) {
53 9
                $dictionary = (array) include $segment;
54 9
                $callback($dictionary);
55 9
            }
56 9
        }
57 9
    }
58
59
    /**
60
     * Load surname dict.
61
     *
62
     * @param Closure $callback
63
     */
64 1
    public function mapSurname(Closure $callback)
65
    {
66 1
        $surnames = $this->path.'/surname';
67
        
68 1
        if (file_exists($surnames)) {
69 1
            $dictionary = (array) include $surnames;
70 1
            $callback($dictionary);
71 1
        }
72 1
    }
73
}
74