Completed
Push — master ( eaa08c...d2fe44 )
by Mikaël
656:34 queued 656:28
created

AbstractDocument   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 2
dl 0
loc 80
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getElementHandler() 0 12 3
A getNamespaceUri() 0 9 3
1
<?php
2
3
namespace WsdlToPhp\PackageGenerator\WsdlHandler;
4
5
use WsdlToPhp\DomHandler\ElementHandler;
6
use WsdlToPhp\DomHandler\DomDocumentHandler;
7
use WsdlToPhp\DomHandler\AbstractDomDocumentHandler;
8
9
abstract class AbstractDocument extends DomDocumentHandler
10
{
11
    const TAG_ADDRESS = 'address';
12
    const TAG_ALL = 'all';
13
    const TAG_ANNOTATION = 'annotation';
14
    const TAG_ANY = 'any';
15
    const TAG_ANY_ATTRIBUTE = 'anyAttribute';
16
    const TAG_APPINFO = 'appinfo';
17
    const TAG_ATTRIBUTE = 'attribute';
18
    const TAG_ATTRIBUTE_GROUP = 'attributeGroup';
19
    const TAG_BINDING = 'binding';
20
    const TAG_BODY = 'body';
21
    const TAG_CHOICE = 'choice';
22
    const TAG_COMPLEX_CONTENT = 'complexContent';
23
    const TAG_COMPLEX_TYPE = 'complexType';
24
    const TAG_DEFINITIONS = 'definitions';
25
    const TAG_DOCUMENTATION = 'documentation';
26
    const TAG_ELEMENT = 'element';
27
    const TAG_ENUMERATION = 'enumeration';
28
    const TAG_EXTENSION = 'extension';
29
    const TAG_FIELD = 'field';
30
    const TAG_GROUP = 'group';
31
    const TAG_HEADER = 'header';
32
    const TAG_IMPORT = 'import';
33
    const TAG_INCLUDE = 'include';
34
    const TAG_INPUT = 'input';
35
    const TAG_KEY = 'key';
36
    const TAG_KEYREF = 'keyref';
37
    const TAG_LIST = 'list';
38
    const TAG_MEMBER_TYPES = 'memberTypes';
39
    const TAG_MESSAGE = 'message';
40
    const TAG_NOTATION = 'notation';
41
    const TAG_OPERATION = 'operation';
42
    const TAG_OUTPUT = 'output';
43
    const TAG_PART = 'part';
44
    const TAG_PORT = 'port';
45
    const TAG_PORT_TYPE = 'portType';
46
    const TAG_REDEFINE = 'redefine';
47
    const TAG_RESTRICTION = 'restriction';
48
    const TAG_SELECTOR = 'selector';
49
    const TAG_SEQUENCE = 'sequence';
50
    const TAG_SCHEMA = 'schema';
51
    const TAG_SIMPLE_CONTENT = 'simpleContent';
52
    const TAG_SIMPLE_TYPE = 'simpleType';
53
    const TAG_TYPES = 'types';
54
    const TAG_UNION = 'union';
55
    const TAG_UNIQUE = 'unique';
56
    /**
57
     * @param \DOMElement $element
58
     * @param AbstractDomDocumentHandler $domDocument
59
     * @param int $index
60
     * @see \WsdlToPhp\DomHandler\AbstractDomDocumentHandler::getElementHandler()
61
     * @return ElementHandler
62
     */
63
    protected function getElementHandler(\DOMElement $element, AbstractDomDocumentHandler $domDocument, $index = -1)
64
    {
65
        $handlerName = '\WsdlToPhp\DomHandler\ElementHandler';
66
        $elementNameClass = sprintf('%s\Tag\Tag%s', __NAMESPACE__, ucfirst(implode('', array_slice(explode(':', $element->nodeName), -1, 1))));
67
        $tagClass = sprintf('%s\Tag\Tag', __NAMESPACE__);
68
        if (class_exists($elementNameClass)) {
69
            $handlerName = $elementNameClass;
70
        } elseif (class_exists($tagClass)) {
71
            $handlerName = $tagClass;
72
        }
73
        return new $handlerName($element, $domDocument, $index);
74
    }
75
    /**
76
     * @param string $namespace
77
     * @return string
78
     */
79
    public function getNamespaceUri($namespace)
80
    {
81
        $rootElement = $this->getRootElement();
82
        $uri = '';
83
        if ($rootElement instanceof ElementHandler && $rootElement->hasAttribute(sprintf('xmlns:%s', $namespace))) {
84
            $uri = $rootElement->getAttribute(sprintf('xmlns:%s', $namespace))->getValue();
85
        }
86
        return $uri;
87
    }
88
}
89