Test Failed
Pull Request — master (#152)
by Alex
02:46
created
src/Writer/IAttribute.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 {
12 12
     public function getAttributeValue(): ?string;
13 13
 
14
-    public function getAttributeNullCheck():bool ;
14
+    public function getAttributeNullCheck():bool;
15 15
 
16 16
     public function getAttributeForVersion(): OdataVersions;
17 17
 
Please login to merge, or discard this patch.
src/Writer/Namespaces.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      * In this specification the namespace prefix Edm is used to represent the Entity Data Model namespace, however
46 46
      * the prefix name is not prescriptive.
47 47
      */
48
-    private const V1EdmNamespace= 'http://schemas.microsoft.com/ado/2006/04/edm';
48
+    private const V1EdmNamespace = 'http://schemas.microsoft.com/ado/2006/04/edm';
49 49
     private const V2EdmNamespace = 'http://schemas.microsoft.com/ado/2008/09/edm';
50 50
     private const V3EdmNamespace = 'http://schemas.microsoft.com/ado/2009/11/edm';
51 51
     /**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
     public function __construct(OdataVersions $version)
72 72
     {
73
-        switch($version) {
73
+        switch ($version) {
74 74
             case OdataVersions::ONE():
75 75
                 $this->edmNamespace = self::V1EdmNamespace;
76 76
                 break;
@@ -88,19 +88,19 @@  discard block
 block discarded – undo
88 88
     }
89 89
 
90 90
 
91
-    public function getEdmNamespace(){
91
+    public function getEdmNamespace() {
92 92
         return $this->edmNamespace;
93 93
     }
94
-    public function getEdmxNamespace(){
94
+    public function getEdmxNamespace() {
95 95
         return $this->edmxNamespace;
96 96
     }
97
-    public function getMetadataNamespace(){
97
+    public function getMetadataNamespace() {
98 98
         return $this->metadataNamespace;
99 99
     }
100
-    public function getDataServiceNamespace(){
100
+    public function getDataServiceNamespace() {
101 101
         return $this->dataServiceNamespace;
102 102
     }
103
-    public function getAnnotationsNamespace(){
103
+    public function getAnnotationsNamespace() {
104 104
         return $this->annotationsNamespace;
105 105
     }
106 106
 }
107 107
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -88,19 +88,24 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Writer/WritterContext.php 2 patches
Spacing   +21 added lines, -22 removed lines patch added patch discarded remove patch
@@ -35,34 +35,34 @@  discard block
 block discarded – undo
35 35
         return $this->baseDocument;
36 36
     }
37 37
 
38
-    public function getEdmNamespace(){
38
+    public function getEdmNamespace() {
39 39
         return $this->namespaceContainer->getEdmNamespace();
40 40
     }
41
-    public function getEdmxNamespace(){
41
+    public function getEdmxNamespace() {
42 42
         return $this->namespaceContainer->getEdmxNamespace();
43 43
     }
44
-    public function getMetadataNamespace(){
44
+    public function getMetadataNamespace() {
45 45
         return $this->namespaceContainer->getMetadataNamespace();
46 46
     }
47
-    public function getDataServiceNamespace(){
47
+    public function getDataServiceNamespace() {
48 48
         return $this->namespaceContainer->getDataServiceNamespace();
49 49
     }
50
-    public function getAnnotationsNamespace(){
50
+    public function getAnnotationsNamespace() {
51 51
         return $this->namespaceContainer->getAnnotationsNamespace();
52 52
     }
53 53
     public function getOdataVersion():string {
54 54
         return strval($this->odataVersion);
55 55
     }
56 56
 
57
-    public function registerNamespace($prefix, $namespace){
57
+    public function registerNamespace($prefix, $namespace) {
58 58
         $this->namespaceRegister[$prefix] = $namespace;
59 59
     }
60 60
 
61
-    public function getNamespaceForPrefix($prefix){
61
+    public function getNamespaceForPrefix($prefix) {
62 62
         return $this->namespaceRegister[$prefix];
63 63
     }
64 64
 
65
-    protected function createElement($namespace,$name): DOMElement
65
+    protected function createElement($namespace, $name): DOMElement
66 66
     {
67 67
         return $this->baseDocument->createElementNS($namespace, $name);
68 68
     }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         return $this->odataVersion == OdataVersions::THREE();
88 88
 
89 89
     }
90
-    public function getXml(){
90
+    public function getXml() {
91 91
         return $this->baseDocument->saveXML();
92 92
     }
93 93
 
@@ -99,20 +99,20 @@  discard block
 block discarded – undo
99 99
     public function write(DomBase $rootNode, bool $isTopLevel = true): DOMElement{
100 100
         $prefix = null;
101 101
         $qualifiedName = $rootNode->getDomName();
102
-        if(strpos($qualifiedName, ':') !== false) {
103
-            $prefix = substr($qualifiedName,0,strpos($qualifiedName, ':'));
102
+        if (strpos($qualifiedName, ':') !== false) {
103
+            $prefix = substr($qualifiedName, 0, strpos($qualifiedName, ':'));
104 104
         }
105 105
         $domElement = $this->baseDocument->createElementNS($this->getNamespaceForPrefix($prefix), $qualifiedName);
106
-        if($isTopLevel){
106
+        if ($isTopLevel) {
107 107
             $this->setUpNamespaces($domElement);
108 108
         }
109 109
 
110 110
         $domElement->textContent = $rootNode->getTextContent();
111 111
 
112
-        foreach( $rootNode->getAttributes() as $attribute){
113
-            $attribute->apply($domElement, $this );
112
+        foreach ($rootNode->getAttributes() as $attribute) {
113
+            $attribute->apply($domElement, $this);
114 114
         }
115
-        foreach(array_filter($rootNode->getChildElements()) as $childNode){
115
+        foreach (array_filter($rootNode->getChildElements()) as $childNode) {
116 116
             $childElement = $this->write($childNode, false);
117 117
 
118 118
             $domElement->appendChild($childElement);
@@ -123,19 +123,18 @@  discard block
 block discarded – undo
123 123
 
124 124
     public function writeAttribute(DomElement $element, IAttribute $attribute)
125 125
     {
126
-        if((null == $attribute->getValue() && $attribute->getNullCheck()) || !$this->shouldWrite($attribute)){
126
+        if ((null == $attribute->getValue() && $attribute->getNullCheck()) || !$this->shouldWrite($attribute)) {
127 127
             return;
128 128
         }
129 129
         null === $attribute->getPrefix() ?
130
-            $element->setAttribute($attribute->getName(), $attribute->getValue()) :
131
-            $element->setAttributeNS(
130
+            $element->setAttribute($attribute->getName(), $attribute->getValue()) : $element->setAttributeNS(
132 131
                 $this->getNamespaceForPrefix($attribute->getPrefix()),
133 132
                 $attribute->getPrefix() . ":" . $attribute->getName(),
134 133
                 $attribute->getValue()
135 134
             );
136 135
     }
137 136
 
138
-    protected function shouldWrite(IAttribute $attribute){
137
+    protected function shouldWrite(IAttribute $attribute) {
139 138
         return
140 139
             (
141 140
                 OdataVersions::TWO() == $attribute->getForVersion() && $this->shouldWriteV2() ||
@@ -145,15 +144,15 @@  discard block
 block discarded – undo
145 144
             !in_array($this->getOdataVersion(), $attribute->getProhibitedVersion());
146 145
     }
147 146
 
148
-    private function registerNamespaces(){
147
+    private function registerNamespaces() {
149 148
         $this->registerNamespace(null, $this->getEdmNamespace());
150 149
         $this->registerNamespace("annotations", $this->getAnnotationsNamespace());
151 150
         $this->registerNamespace('metadata', $this->getMetadataNamespace());
152 151
         $this->registerNamespace('edmx', $this->getEdmxNamespace());
153 152
     }
154 153
 
155
-    private function setUpNamespaces(DOMElement $rootElement){
156
-        foreach($this->namespaceRegister as $prefix => $namespace){
154
+    private function setUpNamespaces(DOMElement $rootElement) {
155
+        foreach ($this->namespaceRegister as $prefix => $namespace) {
157 156
             $qualifiedName = $prefix === "" ? 'xmlns' : 'xmlns:' . $prefix;
158 157
             $rootElement->setAttributeNS(
159 158
                 'http://www.w3.org/2000/xmlns/',
Please login to merge, or discard this patch.
Braces   +27 added lines, -16 removed lines patch added patch discarded remove patch
@@ -35,30 +35,37 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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/',
Please login to merge, or discard this patch.
src/Writer/AttributeContainer.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
     private function strval($value):string
111 111
     {
112
-        if(is_bool($value)){
112
+        if (is_bool($value)) {
113 113
             return $value ? "true" : "false";
114 114
         }
115 115
         return strval($value);
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     public function setAttributeName(string $name): AttributeContainer
134 134
     {
135 135
         $prefix = null;
136
-        if(strpos($name, ':') !== false) {
136
+        if (strpos($name, ':') !== false) {
137 137
             list($prefix, $name) = explode(":", $name);
138 138
         }
139 139
         $this->name = $name;
Please login to merge, or discard this patch.
Braces   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -97,8 +97,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.