@@ -147,6 +147,9 @@ |
||
147 | 147 | return $datetime; |
148 | 148 | } |
149 | 149 | |
150 | + /** |
|
151 | + * @param string $interval |
|
152 | + */ |
|
150 | 153 | private function createDateInterval($interval){ |
151 | 154 | $f = 0.0; |
152 | 155 | if (preg_match('~\.\d+~',$interval,$match)) { |
@@ -63,77 +63,77 @@ |
||
63 | 63 | |
64 | 64 | public function __construct($defaultTimezone = 'UTC') |
65 | 65 | { |
66 | - $this->defaultTimezone = new \DateTimeZone($defaultTimezone); |
|
66 | + $this->defaultTimezone = new \DateTimeZone ($defaultTimezone); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | |
70 | - public function deserializeDateIntervalXml(JsonDeserializationVisitor $visitor, $data, array $type){ |
|
71 | - return $this->createDateInterval((string)$data); |
|
70 | + public function deserializeDateIntervalXml(JsonDeserializationVisitor $visitor, $data, array $type) { |
|
71 | + return $this->createDateInterval ((string) $data); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | public function serializeDate(JsonSerializationVisitor $visitor, \DateTime $date, array $type, Context $context) |
75 | 75 | { |
76 | - return $date->format('Y-m-d'); |
|
76 | + return $date->format ('Y-m-d'); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | public function deserializeDate(JsonDeserializationVisitor $visitor, $data, array $type) |
80 | 80 | { |
81 | - if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})(Z|([+-]\d{2}:\d{2}))?$/', $data)) { |
|
82 | - throw new RuntimeException(sprintf('Invalid date "%s", expected valid XML Schema date string.', $data)); |
|
81 | + if (!preg_match ('/^(\d{4})-(\d{2})-(\d{2})(Z|([+-]\d{2}:\d{2}))?$/', $data)) { |
|
82 | + throw new RuntimeException (sprintf ('Invalid date "%s", expected valid XML Schema date string.', $data)); |
|
83 | 83 | } |
84 | 84 | |
85 | - return $this->parseDateTime($data, $type); |
|
85 | + return $this->parseDateTime ($data, $type); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | public function serializeDateTime(JsonSerializationVisitor $visitor, \DateTime $date, array $type, Context $context) |
89 | 89 | { |
90 | 90 | |
91 | - return $date->format(\DateTime::W3C); |
|
91 | + return $date->format (\DateTime::W3C); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | public function deserializeDateTime(JsonDeserializationVisitor $visitor, $data, array $type) |
95 | 95 | { |
96 | - return $this->parseDateTime($data, $type); |
|
96 | + return $this->parseDateTime ($data, $type); |
|
97 | 97 | |
98 | 98 | } |
99 | 99 | |
100 | 100 | public function serializeTime(JsonSerializationVisitor $visitor, \DateTime $date, array $type, Context $context) |
101 | 101 | { |
102 | - $v = $date->format('H:i:s'); |
|
103 | - if ($date->getTimezone()->getOffset($date) !== $this->defaultTimezone->getOffset($date)) { |
|
104 | - $v .= $date->format('P'); |
|
102 | + $v = $date->format ('H:i:s'); |
|
103 | + if ($date->getTimezone ()->getOffset ($date) !== $this->defaultTimezone->getOffset ($date)) { |
|
104 | + $v .= $date->format ('P'); |
|
105 | 105 | } |
106 | 106 | return $v; |
107 | 107 | } |
108 | 108 | |
109 | 109 | public function deserializeTime(JsonDeserializationVisitor $visitor, $data, array $type) |
110 | 110 | { |
111 | - $data = (string)$data; |
|
111 | + $data = (string) $data; |
|
112 | 112 | |
113 | - return new \DateTime($data, $this->defaultTimezone); |
|
113 | + return new \DateTime ($data, $this->defaultTimezone); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | private function parseDateTime($data, array $type) |
117 | 117 | { |
118 | - $timezone = isset($type['params'][1]) ? new \DateTimeZone($type['params'][1]) : $this->defaultTimezone; |
|
119 | - $datetime = new \DateTime((string)$data, $timezone); |
|
118 | + $timezone = isset($type['params'][1]) ? new \DateTimeZone ($type['params'][1]) : $this->defaultTimezone; |
|
119 | + $datetime = new \DateTime ((string) $data, $timezone); |
|
120 | 120 | if (false === $datetime) { |
121 | - throw new RuntimeException(sprintf('Invalid datetime "%s", expected valid XML Schema dateTime string.', $data)); |
|
121 | + throw new RuntimeException (sprintf ('Invalid datetime "%s", expected valid XML Schema dateTime string.', $data)); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | return $datetime; |
125 | 125 | } |
126 | 126 | |
127 | - private function createDateInterval($interval){ |
|
127 | + private function createDateInterval($interval) { |
|
128 | 128 | $f = 0.0; |
129 | - if (preg_match('~\.\d+~',$interval,$match)) { |
|
130 | - $interval = str_replace($match[0], "", $interval); |
|
131 | - $f = (float)$match[0]; |
|
129 | + if (preg_match ('~\.\d+~', $interval, $match)) { |
|
130 | + $interval = str_replace ($match[0], "", $interval); |
|
131 | + $f = (float) $match[0]; |
|
132 | 132 | } |
133 | - $di = new \DateInterval($interval); |
|
133 | + $di = new \DateInterval ($interval); |
|
134 | 134 | // milliseconds are only available from >=7.1 |
135 | - if(isset($di->f)){ |
|
136 | - $di->f= $f; |
|
135 | + if (isset($di->f)) { |
|
136 | + $di->f = $f; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | return $di; |