DocumentAbstract   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A factoryTag() 0 15 3
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;
16
17
abstract class DocumentAbstract extends \DOMDocument implements DocumentInterface
18
{
19
    const ENCONDING = 'utf-8';
20
21
    public $docset;
22
23
    protected $elementPrefix = '';
24
25
    public function __construct()
26
    {
27
        parent::__construct('1.0', self::ENCONDING);
28
        $comment = $this->createComment(' Generate by Pipe2 on ['.date('r')
29
            .'] | For more information, see <https://opensource.gpupo.com/pipe2/> ');
30
        $this->appendChild($comment);
31
    }
32
33
    /**
34
     * Factory DOMElement.
35
     *
36
     * @param string $type
37
     * @param string $key
38
     * @param mixed  $prop
39
     *
40
     * @return \DOMElement
41
     */
42
    protected function factoryTag($type, $key, $prop)
43
    {
44
        $tag = $this->createElement($this->elementPrefix.$type);
45
46
        if (is_array($prop)) {
47
            $tag->setAttribute('name', $key);
48
            foreach ($prop as $k => $v) {
49
                $tag->setAttribute($k, $v);
50
            }
51
        } else {
52
            $tag->setAttribute('name', $prop);
53
        }
54
55
        return $tag;
56
    }
57
}
58