@@ -43,7 +43,8 @@ |
||
43 | 43 | unset($this->property[$offset]); |
44 | 44 | } |
45 | 45 | |
46 | - public function __toArray(){ |
|
46 | + public function __toArray() |
|
47 | + { |
|
47 | 48 | return $this->property; |
48 | 49 | } |
49 | 50 | } |
50 | 51 | \ No newline at end of file |
@@ -42,7 +42,8 @@ |
||
42 | 42 | unset($this->property[$offset]); |
43 | 43 | } |
44 | 44 | |
45 | - public function __toArray(){ |
|
45 | + public function __toArray() |
|
46 | + { |
|
46 | 47 | return $this->property; |
47 | 48 | } |
48 | 49 | } |
49 | 50 | \ No newline at end of file |
@@ -88,19 +88,24 @@ |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | |
91 | - public function getEdmNamespace(){ |
|
91 | + public function getEdmNamespace() |
|
92 | + { |
|
92 | 93 | return $this->edmNamespace; |
93 | 94 | } |
94 | - public function getEdmxNamespace(){ |
|
95 | + public function getEdmxNamespace() |
|
96 | + { |
|
95 | 97 | return $this->edmxNamespace; |
96 | 98 | } |
97 | - public function getMetadataNamespace(){ |
|
99 | + public function getMetadataNamespace() |
|
100 | + { |
|
98 | 101 | return $this->metadataNamespace; |
99 | 102 | } |
100 | - public function getDataServiceNamespace(){ |
|
103 | + public function getDataServiceNamespace() |
|
104 | + { |
|
101 | 105 | return $this->dataServiceNamespace; |
102 | 106 | } |
103 | - public function getAnnotationsNamespace(){ |
|
107 | + public function getAnnotationsNamespace() |
|
108 | + { |
|
104 | 109 | return $this->annotationsNamespace; |
105 | 110 | } |
106 | 111 | } |
107 | 112 | \ No newline at end of file |
@@ -35,30 +35,37 @@ discard block |
||
35 | 35 | return $this->baseDocument; |
36 | 36 | } |
37 | 37 | |
38 | - public function getEdmNamespace(){ |
|
38 | + public function getEdmNamespace() |
|
39 | + { |
|
39 | 40 | return $this->namespaceContainer->getEdmNamespace(); |
40 | 41 | } |
41 | - public function getEdmxNamespace(){ |
|
42 | + public function getEdmxNamespace() |
|
43 | + { |
|
42 | 44 | return $this->namespaceContainer->getEdmxNamespace(); |
43 | 45 | } |
44 | - public function getMetadataNamespace(){ |
|
46 | + public function getMetadataNamespace() |
|
47 | + { |
|
45 | 48 | return $this->namespaceContainer->getMetadataNamespace(); |
46 | 49 | } |
47 | - public function getDataServiceNamespace(){ |
|
50 | + public function getDataServiceNamespace() |
|
51 | + { |
|
48 | 52 | return $this->namespaceContainer->getDataServiceNamespace(); |
49 | 53 | } |
50 | - public function getAnnotationsNamespace(){ |
|
54 | + public function getAnnotationsNamespace() |
|
55 | + { |
|
51 | 56 | return $this->namespaceContainer->getAnnotationsNamespace(); |
52 | 57 | } |
53 | 58 | public function getOdataVersion():string { |
54 | 59 | return strval($this->odataVersion); |
55 | 60 | } |
56 | 61 | |
57 | - public function registerNamespace($prefix, $namespace){ |
|
62 | + public function registerNamespace($prefix, $namespace) |
|
63 | + { |
|
58 | 64 | $this->namespaceRegister[$prefix] = $namespace; |
59 | 65 | } |
60 | 66 | |
61 | - public function getNamespaceForPrefix($prefix){ |
|
67 | + public function getNamespaceForPrefix($prefix) |
|
68 | + { |
|
62 | 69 | return $this->namespaceRegister[$prefix]; |
63 | 70 | } |
64 | 71 | |
@@ -87,7 +94,8 @@ discard block |
||
87 | 94 | return $this->odataVersion == OdataVersions::THREE(); |
88 | 95 | |
89 | 96 | } |
90 | - public function getXml(){ |
|
97 | + public function getXml() |
|
98 | + { |
|
91 | 99 | return $this->baseDocument->saveXML(); |
92 | 100 | } |
93 | 101 | |
@@ -103,16 +111,16 @@ discard block |
||
103 | 111 | $prefix = substr($qualifiedName,0,strpos($qualifiedName, ':')); |
104 | 112 | } |
105 | 113 | $domElement = $this->baseDocument->createElementNS($this->getNamespaceForPrefix($prefix), $qualifiedName); |
106 | - if($isTopLevel){ |
|
114 | + if($isTopLevel) { |
|
107 | 115 | $this->setUpNamespaces($domElement); |
108 | 116 | } |
109 | 117 | |
110 | 118 | $domElement->textContent = $rootNode->getTextContent(); |
111 | 119 | |
112 | - foreach( $rootNode->getAttributes() as $attribute){ |
|
120 | + foreach( $rootNode->getAttributes() as $attribute) { |
|
113 | 121 | $attribute->apply($domElement, $this ); |
114 | 122 | } |
115 | - foreach(array_filter($rootNode->getChildElements()) as $childNode){ |
|
123 | + foreach(array_filter($rootNode->getChildElements()) as $childNode) { |
|
116 | 124 | $childElement = $this->write($childNode, false); |
117 | 125 | |
118 | 126 | $domElement->appendChild($childElement); |
@@ -123,7 +131,7 @@ discard block |
||
123 | 131 | |
124 | 132 | public function writeAttribute(DomElement $element, IAttribute $attribute) |
125 | 133 | { |
126 | - if((null == $attribute->getValue() && $attribute->getNullCheck()) || !$this->shouldWrite($attribute)){ |
|
134 | + if((null == $attribute->getValue() && $attribute->getNullCheck()) || !$this->shouldWrite($attribute)) { |
|
127 | 135 | return; |
128 | 136 | } |
129 | 137 | null === $attribute->getPrefix() ? |
@@ -135,7 +143,8 @@ discard block |
||
135 | 143 | ); |
136 | 144 | } |
137 | 145 | |
138 | - protected function shouldWrite(IAttribute $attribute){ |
|
146 | + protected function shouldWrite(IAttribute $attribute) |
|
147 | + { |
|
139 | 148 | return |
140 | 149 | ( |
141 | 150 | OdataVersions::TWO() == $attribute->getForVersion() && $this->shouldWriteV2() || |
@@ -145,15 +154,17 @@ discard block |
||
145 | 154 | !in_array($this->getOdataVersion(), $attribute->getProhibitedVersion()); |
146 | 155 | } |
147 | 156 | |
148 | - private function registerNamespaces(){ |
|
157 | + private function registerNamespaces() |
|
158 | + { |
|
149 | 159 | $this->registerNamespace(null, $this->getEdmNamespace()); |
150 | 160 | $this->registerNamespace("annotations", $this->getAnnotationsNamespace()); |
151 | 161 | $this->registerNamespace('metadata', $this->getMetadataNamespace()); |
152 | 162 | $this->registerNamespace('edmx', $this->getEdmxNamespace()); |
153 | 163 | } |
154 | 164 | |
155 | - private function setUpNamespaces(DOMElement $rootElement){ |
|
156 | - foreach($this->namespaceRegister as $prefix => $namespace){ |
|
165 | + private function setUpNamespaces(DOMElement $rootElement) |
|
166 | + { |
|
167 | + foreach($this->namespaceRegister as $prefix => $namespace) { |
|
157 | 168 | $qualifiedName = $prefix === "" ? 'xmlns' : 'xmlns:' . $prefix; |
158 | 169 | $rootElement->setAttributeNS( |
159 | 170 | 'http://www.w3.org/2000/xmlns/', |
@@ -97,8 +97,7 @@ discard block |
||
97 | 97 | bool $nullCheck = false, |
98 | 98 | OdataVersions $forVersion = null, |
99 | 99 | array $prohibitedVersions = [] |
100 | - ) |
|
101 | - { |
|
100 | + ) { |
|
102 | 101 | $this |
103 | 102 | ->setAttributeName($name) |
104 | 103 | ->setAttributeForVersion($forVersion) |
@@ -109,7 +108,7 @@ discard block |
||
109 | 108 | |
110 | 109 | private function strval($value):string |
111 | 110 | { |
112 | - if(is_bool($value)){ |
|
111 | + if(is_bool($value)) { |
|
113 | 112 | return $value ? "true" : "false"; |
114 | 113 | } |
115 | 114 | return strval($value); |