Merge::execute()   B
last analyzed

Complexity

Conditions 7
Paths 16

Size

Total Lines 34
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 7
eloc 15
nc 16
nop 2
dl 0
loc 34
rs 8.8333
c 1
b 0
f 0
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