CrapMethodMerger   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 41
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getMethods() 0 11 3
1
<?php
2
3
4
namespace TheCodingMachine\WashingMachine\Clover;
5
6
/**
7
 * Merges crap methods from Clover and Crap4J
8
 */
9
class CrapMethodMerger implements CrapMethodFetcherInterface
10
{
11
    /**
12
     * @var CrapMethodFetcherInterface
13
     */
14
    private $file1;
15
    /**
16
     * @var CrapMethodFetcherInterface
17
     */
18
    private $file2;
19
20
    /**
21
     * Merges methods from file 2 into methods from file 1
22
     *
23
     * @param CrapMethodFetcherInterface $file1
24
     * @param CrapMethodFetcherInterface $file2
25
     */
26
    public function __construct(CrapMethodFetcherInterface $file1, CrapMethodFetcherInterface $file2)
27
    {
28
29
        $this->file1 = $file1;
30
        $this->file2 = $file2;
31
    }
32
33
    /**
34
     * Returns an array of method objects, indexed by method full name.
35
     *
36
     * @return Method[]
37
     */
38
    public function getMethods(): array
39
    {
40
        $methods = $this->file1->getMethods();
41
        $toMergeMethods = $this->file2->getMethods();
42
43
        foreach ($toMergeMethods as $name => $toMergeMethod) {
44
            $methods[$name] = isset($methods[$name]) ? $methods[$name]->merge($toMergeMethod) : $toMergeMethod;
45
        }
46
47
        return $methods;
48
    }
49
}
50