Elastica\Query\HasChild::toArray PHP Method

toArray() public method

public toArray ( )
    public function toArray()
    {
        $array = parent::toArray();
        $baseName = $this->_getBaseName();
        if (isset($array[$baseName]['query'])) {
            $array[$baseName]['query'] = $array[$baseName]['query']['query'];
        }
        return $array;
    }

Usage Example

 /**
  * @group unit
  */
 public function testSetScope()
 {
     $q = new MatchAll();
     $type = 'test';
     $scope = 'foo';
     $query = new HasChild($q, $type);
     $query->setScope($scope);
     $expectedArray = array('has_child' => array('query' => $q->toArray(), 'type' => $type, '_scope' => $scope));
     $this->assertEquals($expectedArray, $query->toArray());
 }