Merge   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 41
rs 10
c 1
b 0
f 0
wmc 7

1 Method

Rating   Name   Duplication   Size   Complexity  
B execute() 0 34 7
1
<?php
2
declare(strict_types=1);
3
namespace Watchmaker\lib;
4
5
class Merge
6
{
7
    /**
8
     * @param $watchmakerList
9
     * @param $cronList
10
     * @return array
11
     */
12
    public static function execute($watchmakerList, $cronList/*, $skipUnManage = false*/): array
13
    {
14
        $newList = [];
15
16
        // check cron only
17
        foreach ($cronList as $cron)
18
        {
19
            $cronLine = $cron->generate();
20
            foreach ($watchmakerList as $watchmaker)
21
            {
22
                if ($cronLine === $watchmaker->generate()) {
23
                    continue 2;
24
                }
25
            }
26
27
            $newList[] = $cron->cronOnly();
28
        }
29
30
        // check install or not install
31
        foreach ($watchmakerList as $watchmaker)
32
        {
33
            $watchmakerLine = $watchmaker->generate();
34
            foreach ($cronList as $cron)
35
            {
36
                if ($watchmakerLine === $cron->generate()) {
37
                    $newList[] = $watchmaker->installed();
38
                    continue 2;
39
                }
40
            }
41
42
            $newList[] = $watchmaker->notInstalled();
43
        }
44
45
        return $newList;
46
    }
47
}
48