Document   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 2
dl 0
loc 33
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C __construct() 0 30 7
1
<?php
2
3
/*
4
 * This file is part of gpupo/pipe2
5
 *
6
 * (c) Gilmar Pupo <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * For more information, see
12
 * <https://opensource.gpupo.com/pipe2/>.
13
 */
14
15
namespace Gpupo\Pipe2\Merge\Attributes;
16
17
use Gpupo\Pipe2\DocumentAbstract;
18
19
class Document extends DocumentAbstract
20
{
21
    public function __construct(Collection $meta)
22
    {
23
        parent::__construct();
24
        $this->docset = $this->createElement('channel');
25
        $rss = $this->createElement('rss');
26
27
        if ($meta->containsKey('rss')) {
28
            foreach ($meta->get('rss') as $attr => $value) {
29
                $rss->setAttribute($attr, $value);
30
            }
31
        }
32
33
        foreach ($meta as $key => $value) {
34
            if (empty($value)) {
35
                continue;
36
            }
37
38
            if (is_array($value)) {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
39
            } else {
40
                $new = $this->createElement($key, $value);
41
            }
42
            if (isset($new)) {
43
                $this->docset->appendChild($new);
44
                unset($new);
45
            }
46
        }
47
48
        $rss->appendChild($this->docset);
49
        $this->appendChild($rss);
50
    }
51
}
52