Elastica\Query\GeoShapeProvided::toArray PHP Метод

toArray() публичный Метод

Converts query to array.
См. также: Elastica\Query\AbstractQuery::toArray()
public toArray ( ) : array
Результат array
    public function toArray()
    {
        return ['geo_shape' => [$this->_path => ['shape' => ['type' => $this->_shapeType, 'coordinates' => $this->_coordinates, 'relation' => $this->_relation]]]];
    }

Usage Example

 /**
  * @group unit
  */
 public function testConstructPolygon()
 {
     $polygon = array(array(102.0, 2.0), array(103.0, 2.0), array(103.0, 3.0), array(103.0, 3.0), array(102.0, 2.0));
     $gsp = new GeoShapeProvided('location', $polygon, GeoShapeProvided::TYPE_POLYGON);
     $expected = array('geo_shape' => array('location' => array('shape' => array('type' => GeoShapeProvided::TYPE_POLYGON, 'coordinates' => $polygon, 'relation' => $gsp->getRelation()))));
     $this->assertEquals($expected, $gsp->toArray());
 }
GeoShapeProvided