Completed
Push — master ( cb2c73...1a2628 )
by Aleh
12s
created

UseCompleter::getEntries()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 20
Code Lines 15

Duplication

Lines 20
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 20
loc 20
rs 9.2
cc 4
eloc 15
nc 3
nop 2
1
<?php
2
3
namespace Padawan\Domain\Completer;
4
5
use Padawan\Domain\Core\Project;
6
use Padawan\Domain\Core\Completion\Context;
7
use Padawan\Domain\Core\Completion\Entry;
8
9 View Code Duplication
class UseCompleter extends AbstractFileInfoCompleter
0 ignored issues
show
Duplication introduced by
This class 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...
10
{
11
    public function getEntries(Project $project, Context $context)
12
    {
13
        $entries = [];
14
        $postfix = trim($context->getData());
15
        $index = $project->getIndex();
16
        $fqcns = array_merge($index->getClasses(), $index->getInterfaces());
17
        foreach ($fqcns as $fqcn => $class) {
18
            if (!empty($postfix) && strpos($fqcn, $postfix) === false) {
19
                continue;
20
            }
21
            $complete = str_replace($postfix, "", $fqcn);
22
            $entries[] = new Entry(
23
                $complete,
24
                '',
25
                '',
26
                $fqcn
27
            );
28
        }
29
        return $entries;
30
    }
31
32
    public function canHandle(Project $project, Context $context)
33
    {
34
        return parent::canHandle($project, $context) && $context->isUse();
35
    }
36
}
37