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   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
c 2
b 0
f 0
lcom 1
cbo 0
dl 0
loc 58
ccs 19
cts 19
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A map() 0 11 3
A mapSurname() 0 9 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