A simple question why do i need to have __toString in composite value objects such as GeoPoint ?
Option 1 :
class GeoPoint
{
public function __construct(Latitude $lat, Longitude $long)
{
// do some work to check values and set them
}
public static function fromString()
{
// parse object from string
}
public function __toString()
{
// to string representation
}
}
Option 2 :
class GeoPoint
{
public function __construct(Latitude $lat, Longitude $long)
{
// do some work to check values and set them
}
public static function fromNative($lat, $long)
{
// parse object from $lat, $long pair
}
}
wouldn't be a better to go with option 2 ?
Aucun commentaire:
Enregistrer un commentaire