LcomAnalyzer::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 7
Ratio 100 %
Metric Value
dl 7
loc 7
rs 9.4286
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
/*
4
 * (c) Jean-François Lépine <https://twitter.com/Halleck45>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Hal\Application\Command\Job\Analyze;
11
12
use Hal\Component\OOP\Extractor\ClassMap;
13
use Hal\Component\Result\ResultCollection;
14
use Hal\Metrics\Complexity\Structural\LCOM\FileLackOfCohesionOfMethods;
15
16
17
/**
18
 * Starts analyze of Lack of cohesion of methods
19
 *
20
 * @author Jean-François Lépine <https://twitter.com/Halleck45>
21
 */
22 View Code Duplication
class LcomAnalyzer
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...
23
{
24
25
    /**
26
     * @var ClassMap
27
     */
28
    private $classMap;
29
30
    /**
31
     * @var ResultCollection
32
     */
33
    private $collection;
34
35
    /**
36
     * Constructor
37
     *
38
     * @param ClassMap $classMap
39
     * @param ResultCollection $collection
40
     */
41
    public function __construct(ClassMap $classMap, ResultCollection $collection)
42
    {
43
        $this->classMap = $classMap;
44
        $this->collection = $collection;
45
    }
46
47
48
    public function execute(array $files) {
49
        $fileCoupling = new FileLackOfCohesionOfMethods($this->classMap);
50
        foreach($files as $filename) {
51
            $result = $fileCoupling->calculate($filename);
52
            $this->collection->get($filename)->setLcom($result);
53
        }
54
    }
55
56
}
57