@@ -69,19 +69,19 @@ discard block |
||
69 | 69 | |
70 | 70 | public function __construct($defaultTimezone = 'UTC') |
71 | 71 | { |
72 | - $this->defaultTimezone = new \DateTimeZone($defaultTimezone); |
|
72 | + $this->defaultTimezone = new \DateTimeZone ($defaultTimezone); |
|
73 | 73 | |
74 | 74 | } |
75 | 75 | |
76 | - public function deserializeDateIntervalXml(XmlDeserializationVisitor $visitor, $data, array $type){ |
|
77 | - $attributes = $data->attributes('xsi', true); |
|
76 | + public function deserializeDateIntervalXml(XmlDeserializationVisitor $visitor, $data, array $type) { |
|
77 | + $attributes = $data->attributes ('xsi', true); |
|
78 | 78 | if (isset($attributes['nil'][0]) && (string) $attributes['nil'][0] === 'true') { |
79 | 79 | return null; |
80 | 80 | } |
81 | 81 | |
82 | 82 | //Accept negative intervals like -PT1M23S. Safe to assume that "-" doesn't exist elsewhere in a valid interval spec. |
83 | - $interval = str_replace('-', '', (string)$data, $count); |
|
84 | - $dateInterval = new \DateInterval($interval); |
|
83 | + $interval = str_replace ('-', '', (string) $data, $count); |
|
84 | + $dateInterval = new \DateInterval ($interval); |
|
85 | 85 | |
86 | 86 | //Invert if a negative sign was found |
87 | 87 | $dateInterval->invert = !!$count; |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | |
92 | 92 | public function serializeDateInterval(XmlSerializationVisitor $visitor, \DateInterval $interval, array $type, Context $context) |
93 | 93 | { |
94 | - $date = array_filter(array( |
|
94 | + $date = array_filter (array( |
|
95 | 95 | 'Y' => $interval->y, |
96 | 96 | 'M' => $interval->m, |
97 | 97 | 'D' => $interval->d |
98 | 98 | )); |
99 | 99 | |
100 | 100 | // Reading all non-zero time parts. |
101 | - $time = array_filter(array( |
|
101 | + $time = array_filter (array( |
|
102 | 102 | 'H' => $interval->h, |
103 | 103 | 'M' => $interval->i, |
104 | 104 | 'S' => $interval->s |
@@ -108,85 +108,85 @@ discard block |
||
108 | 108 | |
109 | 109 | // Adding each part to the spec-string. |
110 | 110 | foreach ($date as $key => $value) { |
111 | - $specString .= $value . $key; |
|
111 | + $specString .= $value.$key; |
|
112 | 112 | } |
113 | - if (count($time) > 0) { |
|
113 | + if (count ($time) > 0) { |
|
114 | 114 | $specString .= 'T'; |
115 | 115 | foreach ($time as $key => $value) { |
116 | - $specString .= $value . $key; |
|
116 | + $specString .= $value.$key; |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - return $visitor->visitSimpleString($specString, $type, $context); |
|
120 | + return $visitor->visitSimpleString ($specString, $type, $context); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | public function serializeDateIntercal(XmlSerializationVisitor $visitor, \DateTime $date, array $type, Context $context) |
124 | 124 | { |
125 | 125 | |
126 | - $v = $date->format('Y-m-d'); |
|
126 | + $v = $date->format ('Y-m-d'); |
|
127 | 127 | |
128 | - return $visitor->visitSimpleString($v, $type, $context); |
|
128 | + return $visitor->visitSimpleString ($v, $type, $context); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | public function deserializeDate(XmlDeserializationVisitor $visitor, $data, array $type) |
132 | 132 | { |
133 | - $attributes = $data->attributes('xsi', true); |
|
134 | - if (isset($attributes['nil'][0]) && (string)$attributes['nil'][0] === 'true') { |
|
133 | + $attributes = $data->attributes ('xsi', true); |
|
134 | + if (isset($attributes['nil'][0]) && (string) $attributes['nil'][0] === 'true') { |
|
135 | 135 | return null; |
136 | 136 | } |
137 | - if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})(Z|([+-]\d{2}:\d{2}))?$/', $data)) { |
|
138 | - throw new RuntimeException(sprintf('Invalid date "%s", expected valid XML Schema date string.', $data)); |
|
137 | + if (!preg_match ('/^(\d{4})-(\d{2})-(\d{2})(Z|([+-]\d{2}:\d{2}))?$/', $data)) { |
|
138 | + throw new RuntimeException (sprintf ('Invalid date "%s", expected valid XML Schema date string.', $data)); |
|
139 | 139 | } |
140 | 140 | |
141 | - return $this->parseDateTime($data, $type); |
|
141 | + return $this->parseDateTime ($data, $type); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | public function serializeDateTime(XmlSerializationVisitor $visitor, \DateTime $date, array $type, Context $context) |
145 | 145 | { |
146 | 146 | |
147 | - $v = $date->format(\DateTime::W3C); |
|
147 | + $v = $date->format (\DateTime::W3C); |
|
148 | 148 | |
149 | - return $visitor->visitSimpleString($v, $type, $context); |
|
149 | + return $visitor->visitSimpleString ($v, $type, $context); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | public function deserializeDateTime(XmlDeserializationVisitor $visitor, $data, array $type) |
153 | 153 | { |
154 | - $attributes = $data->attributes('xsi', true); |
|
155 | - if (isset($attributes['nil'][0]) && (string)$attributes['nil'][0] === 'true') { |
|
154 | + $attributes = $data->attributes ('xsi', true); |
|
155 | + if (isset($attributes['nil'][0]) && (string) $attributes['nil'][0] === 'true') { |
|
156 | 156 | return null; |
157 | 157 | } |
158 | 158 | |
159 | - return $this->parseDateTime($data, $type); |
|
159 | + return $this->parseDateTime ($data, $type); |
|
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | 163 | public function serializeTime(XmlSerializationVisitor $visitor, \DateTime $date, array $type, Context $context) |
164 | 164 | { |
165 | - $v = $date->format('H:i:s'); |
|
166 | - if ($date->getTimezone()->getOffset($date) !== $this->defaultTimezone->getOffset($date)) { |
|
167 | - $v .= $date->format('P'); |
|
165 | + $v = $date->format ('H:i:s'); |
|
166 | + if ($date->getTimezone ()->getOffset ($date) !== $this->defaultTimezone->getOffset ($date)) { |
|
167 | + $v .= $date->format ('P'); |
|
168 | 168 | } |
169 | - return $visitor->visitSimpleString($v, $type, $context); |
|
169 | + return $visitor->visitSimpleString ($v, $type, $context); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | public function deserializeTime(XmlDeserializationVisitor $visitor, $data, array $type) |
173 | 173 | { |
174 | - $attributes = $data->attributes('xsi', true); |
|
175 | - if (isset($attributes['nil'][0]) && (string)$attributes['nil'][0] === 'true') { |
|
174 | + $attributes = $data->attributes ('xsi', true); |
|
175 | + if (isset($attributes['nil'][0]) && (string) $attributes['nil'][0] === 'true') { |
|
176 | 176 | return null; |
177 | 177 | } |
178 | 178 | |
179 | - $data = (string)$data; |
|
179 | + $data = (string) $data; |
|
180 | 180 | |
181 | - return new \DateTime($data, $this->defaultTimezone); |
|
181 | + return new \DateTime ($data, $this->defaultTimezone); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | private function parseDateTime($data, array $type) |
185 | 185 | { |
186 | - $timezone = isset($type['params'][1]) ? new \DateTimeZone($type['params'][1]) : $this->defaultTimezone; |
|
187 | - $datetime = new \DateTime((string)$data, $timezone); |
|
186 | + $timezone = isset($type['params'][1]) ? new \DateTimeZone ($type['params'][1]) : $this->defaultTimezone; |
|
187 | + $datetime = new \DateTime ((string) $data, $timezone); |
|
188 | 188 | if (false === $datetime) { |
189 | - throw new RuntimeException(sprintf('Invalid datetime "%s", expected valid XML Schema dateTime string.', $data)); |
|
189 | + throw new RuntimeException (sprintf ('Invalid datetime "%s", expected valid XML Schema dateTime string.', $data)); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | return $datetime; |