@@ -92,7 +92,6 @@ The point class:
92
92
.. code-block :: php
93
93
94
94
<?php
95
-
96
95
namespace Geo\ValueObject;
97
96
98
97
class Point
@@ -123,6 +122,14 @@ The point class:
123
122
{
124
123
return $this->longitude;
125
124
}
125
+
126
+ /**
127
+ * @return string
128
+ */
129
+ public function __toString()
130
+ {
131
+ return $this->latitude .' '. $this->longitude;
132
+ }
126
133
}
127
134
128
135
The mapping type
@@ -138,7 +145,6 @@ Now we're going to create the ``point`` type and implement all required methods.
138
145
139
146
use Doctrine\DBAL\Types\Type;
140
147
use Doctrine\DBAL\Platforms\AbstractPlatform;
141
-
142
148
use Geo\ValueObject\Point;
143
149
144
150
class PointType extends Type
@@ -150,22 +156,22 @@ Now we're going to create the ``point`` type and implement all required methods.
150
156
return self::POINT;
151
157
}
152
158
153
- public function getSqlDeclaration (array $fieldDeclaration, AbstractPlatform $platform)
159
+ public function getSQLDeclaration (array $fieldDeclaration, AbstractPlatform $platform)
154
160
{
155
161
return 'POINT';
156
162
}
157
163
158
164
public function convertToPHPValue($value, AbstractPlatform $platform)
159
165
{
160
- list($longitude , $latitude ) = sscanf($value, 'POINT(%f %f)');
166
+ list($latitude , $longitude ) = sscanf($value, 'POINT(%f %f)');
161
167
162
168
return new Point($latitude, $longitude);
163
169
}
164
170
165
171
public function convertToDatabaseValue($value, AbstractPlatform $platform)
166
172
{
167
173
if ($value instanceof Point) {
168
- $value = sprintf('POINT(%F %F)', $value->getLongitude (), $value->getLatitude ());
174
+ $value = sprintf('POINT(%F %F)', $value->getLatitude (), $value->getLongitude ());
169
175
}
170
176
171
177
return $value;
0 commit comments