@@ -64,20 +64,20 @@ discard block |
||
64 | 64 | |
65 | 65 | public function __construct($defaultTimezone = 'UTC') |
66 | 66 | { |
67 | - $this->defaultTimezone = new \DateTimeZone($defaultTimezone); |
|
67 | + $this->defaultTimezone = new \DateTimeZone ($defaultTimezone); |
|
68 | 68 | |
69 | 69 | } |
70 | 70 | |
71 | 71 | public function deserializeDateIntervalXml(XmlDeserializationVisitor $visitor, $data, array $type) |
72 | 72 | { |
73 | - $attributes = $data->attributes('xsi', true); |
|
74 | - if (isset($attributes['nil'][0]) && (string)$attributes['nil'][0] === 'true') { |
|
73 | + $attributes = $data->attributes ('xsi', true); |
|
74 | + if (isset($attributes['nil'][0]) && (string) $attributes['nil'][0] === 'true') { |
|
75 | 75 | return null; |
76 | 76 | } |
77 | 77 | |
78 | 78 | //Accept negative intervals like -PT1M23S. Safe to assume that "-" doesn't exist elsewhere in a valid interval spec. |
79 | - $interval = str_replace('-', '', (string)$data, $count); |
|
80 | - $dateInterval = new \DateInterval($interval); |
|
79 | + $interval = str_replace ('-', '', (string) $data, $count); |
|
80 | + $dateInterval = new \DateInterval ($interval); |
|
81 | 81 | |
82 | 82 | //Invert if a negative sign was found |
83 | 83 | $dateInterval->invert = !!$count; |
@@ -88,70 +88,70 @@ discard block |
||
88 | 88 | public function serializeDate(XmlSerializationVisitor $visitor, \DateTime $date, array $type, Context $context) |
89 | 89 | { |
90 | 90 | |
91 | - $v = $date->format('Y-m-d'); |
|
91 | + $v = $date->format ('Y-m-d'); |
|
92 | 92 | |
93 | - return $visitor->visitSimpleString($v, $type, $context); |
|
93 | + return $visitor->visitSimpleString ($v, $type, $context); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | public function deserializeDate(XmlDeserializationVisitor $visitor, $data, array $type) |
97 | 97 | { |
98 | - $attributes = $data->attributes('xsi', true); |
|
99 | - if (isset($attributes['nil'][0]) && (string)$attributes['nil'][0] === 'true') { |
|
98 | + $attributes = $data->attributes ('xsi', true); |
|
99 | + if (isset($attributes['nil'][0]) && (string) $attributes['nil'][0] === 'true') { |
|
100 | 100 | return null; |
101 | 101 | } |
102 | - if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})(Z|([+-]\d{2}:\d{2}))?$/', $data)) { |
|
103 | - throw new RuntimeException(sprintf('Invalid date "%s", expected valid XML Schema date string.', $data)); |
|
102 | + if (!preg_match ('/^(\d{4})-(\d{2})-(\d{2})(Z|([+-]\d{2}:\d{2}))?$/', $data)) { |
|
103 | + throw new RuntimeException (sprintf ('Invalid date "%s", expected valid XML Schema date string.', $data)); |
|
104 | 104 | } |
105 | 105 | |
106 | - return $this->parseDateTime($data, $type); |
|
106 | + return $this->parseDateTime ($data, $type); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | public function serializeDateTime(XmlSerializationVisitor $visitor, \DateTime $date, array $type, Context $context) |
110 | 110 | { |
111 | 111 | |
112 | - $v = $date->format(\DateTime::W3C); |
|
112 | + $v = $date->format (\DateTime::W3C); |
|
113 | 113 | |
114 | - return $visitor->visitSimpleString($v, $type, $context); |
|
114 | + return $visitor->visitSimpleString ($v, $type, $context); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | public function deserializeDateTime(XmlDeserializationVisitor $visitor, $data, array $type) |
118 | 118 | { |
119 | - $attributes = $data->attributes('xsi', true); |
|
120 | - if (isset($attributes['nil'][0]) && (string)$attributes['nil'][0] === 'true') { |
|
119 | + $attributes = $data->attributes ('xsi', true); |
|
120 | + if (isset($attributes['nil'][0]) && (string) $attributes['nil'][0] === 'true') { |
|
121 | 121 | return null; |
122 | 122 | } |
123 | 123 | |
124 | - return $this->parseDateTime($data, $type); |
|
124 | + return $this->parseDateTime ($data, $type); |
|
125 | 125 | |
126 | 126 | } |
127 | 127 | |
128 | 128 | public function serializeTime(XmlSerializationVisitor $visitor, \DateTime $date, array $type, Context $context) |
129 | 129 | { |
130 | - $v = $date->format('H:i:s'); |
|
131 | - if ($date->getTimezone()->getOffset($date) !== $this->defaultTimezone->getOffset($date)) { |
|
132 | - $v .= $date->format('P'); |
|
130 | + $v = $date->format ('H:i:s'); |
|
131 | + if ($date->getTimezone ()->getOffset ($date) !== $this->defaultTimezone->getOffset ($date)) { |
|
132 | + $v .= $date->format ('P'); |
|
133 | 133 | } |
134 | - return $visitor->visitSimpleString($v, $type, $context); |
|
134 | + return $visitor->visitSimpleString ($v, $type, $context); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | public function deserializeTime(XmlDeserializationVisitor $visitor, $data, array $type) |
138 | 138 | { |
139 | - $attributes = $data->attributes('xsi', true); |
|
140 | - if (isset($attributes['nil'][0]) && (string)$attributes['nil'][0] === 'true') { |
|
139 | + $attributes = $data->attributes ('xsi', true); |
|
140 | + if (isset($attributes['nil'][0]) && (string) $attributes['nil'][0] === 'true') { |
|
141 | 141 | return null; |
142 | 142 | } |
143 | 143 | |
144 | - $data = (string)$data; |
|
144 | + $data = (string) $data; |
|
145 | 145 | |
146 | - return new \DateTime($data, $this->defaultTimezone); |
|
146 | + return new \DateTime ($data, $this->defaultTimezone); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | private function parseDateTime($data, array $type) |
150 | 150 | { |
151 | - $timezone = isset($type['params'][1]) ? new \DateTimeZone($type['params'][1]) : $this->defaultTimezone; |
|
152 | - $datetime = new \DateTime((string)$data, $timezone); |
|
151 | + $timezone = isset($type['params'][1]) ? new \DateTimeZone ($type['params'][1]) : $this->defaultTimezone; |
|
152 | + $datetime = new \DateTime ((string) $data, $timezone); |
|
153 | 153 | if (false === $datetime) { |
154 | - throw new RuntimeException(sprintf('Invalid datetime "%s", expected valid XML Schema dateTime string.', $data)); |
|
154 | + throw new RuntimeException (sprintf ('Invalid datetime "%s", expected valid XML Schema dateTime string.', $data)); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $datetime; |