Completed
Push — master ( 0cffd3...28f6d0 )
by Andrii
02:21
created

src/lib/modifiers/AddCommitLinks.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 commits without link.
17
 *
18
 * @author Andrii Vasyliev <[email protected]>
19
 */
20
class AddCommitLinks extends AbstractModifier
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25 2
    public function run(History $history)
26
    {
27 2
        foreach ($history->getHashes() as $hash) {
28 2
            if (!$history->hasLink($hash)) {
29 1
                $history->addLink($hash, static::generateCommitHref($history, $hash));
30 1
            }
31 2
        }
32 2
    }
33
34
    /**
35
     * Generates href to a commit.
36
     * @param History $history history object
37
     * @param string $hash commit hash
38
     * @return string
39
     */
40 1
    public static function generateCommitHref(History $history, $hash)
41
    {
42 1
        $project = $history->getProject();
43 1
        $rmsSite = $history->getConfig()->rmsSite;
0 ignored issues
show
Accessing rmsSite on the interface hiqdev\chkipper\lib\ConfigInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
44
45 1
        return "https://$rmsSite/$project/commit/$hash";
46
    }
47
}
48