CouplingAnalyzer::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 11
rs 9.4286
cc 2
eloc 7
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
use Hal\Component\OOP\Extractor\ClassMap;
12
use Hal\Component\Result\ResultCollection;
13
use Hal\Metrics\Complexity\Structural\HenryAndKafura\Coupling;
14
use Hal\Metrics\Complexity\Structural\HenryAndKafura\FileCoupling;
15
16
17
/**
18
 * Starts analyze of coupling
19
 *
20
 * @author Jean-François Lépine <https://twitter.com/Halleck45>
21
 */
22
class CouplingAnalyzer
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
        $coupling = new Coupling();
50
        $couplingMap = $coupling->calculate($this->classMap);
51
52
        // link between coupling and files
53
        $fileCoupling = new FileCoupling($this->classMap, $couplingMap);
54
        foreach($files as $filename) {
55
            $rCoupling = $fileCoupling->calculate($filename);
56
            $this->collection->get($filename)->setCoupling($rCoupling);
57
        }
58
    }
59
60
}
61