/** * Save a new model and return the instance. * * @param array $attributes * @return static */ public static function createFromFeature(Feature $feature, array $attributes = []) { $instance = new static(); $properties = [$instance->getPropertiesField() => array_filter($feature->getAllProperties()), $instance->getGeometryField() => $feature->getGeometry()]; $attributes = array_merge($attributes, $properties); return parent::create($attributes); }
public function testSerializationShouldConvertEmptyPropertiesArrayToObject() { $feature = new Feature(null, array()); $expected = array('type' => 'Feature', 'geometry' => null, 'properties' => new \stdClass()); $this->assertEquals($expected, $feature->jsonSerialize()); }