AddAuthorLinks   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 15.38%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 21
ccs 2
cts 13
cp 0.1538
rs 10
c 1
b 0
f 0
wmc 8

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 16 8
1
<?php
2
/**
3
 * Changelog keeper
4
 *
5
 * @link      https://github.com/hiqdev/chkipper
6
 * @package   chkipper
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\chkipper\lib\modifiers;
12
13
use hiqdev\chkipper\lib\History;
14
15
/**
16
 * Modifier that adds links for authors given in config.
17
 *
18
 * @author Andrii Vasyliev <[email protected]>
19
 */
20
class AddAuthorLinks extends AbstractModifier
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25 2
    public function run(History $history)
26
    {
27 2
        foreach (array_reverse($history->getConfig()->getAuthors()) as $nick => $data) {
28
            if (strncmp($nick, '@', 1)) {
29
                $nick = '@' . $nick;
30
            }
31
            $href = !empty($data['github']) ? $data['github'] :
32
                (!empty($data['homepage']) ? $data['homepage'] : null);
33
            if ($history->hasLink($nick) || empty($href)) {
34
                continue;
35
            }
36
37
            if (!empty($data['email'])) {
38
                $history->unshiftLink($data['email'], $href);
39
            }
40
            $history->unshiftLink($nick, $href);
41 2
        }
42 2
    }
43
}
44