collapse() public méthode

Collapse the collection of items into a single array.
public collapse ( ) : static
Résultat static
 public function rowsUngrouped()
 {
     if (!isset($this->rows)) {
         $this->rows = $this->rows();
     }
     return $this->rows instanceof GroupedCollection ? new Collection($this->rows->collapse()) : $this->rows;
 }
 /**
  * @param $resource
  * @param array $arguments
  * @param string $method
  * @return string
  * @throws Exception
  */
 private function call($resource, $arguments, $method)
 {
     try {
         $request = $this->client->{$method}($this->endpoint . $resource, ['headers' => ['Authorization' => 'apikey ' . $this->apikey, 'Content-type' => 'application/json'], 'body' => json_encode($arguments)]);
         $collection = new Collection($request->json());
         if ($collection->count() == 1) {
             return $collection->collapse();
         }
         return $collection;
     } catch (RequestException $e) {
         throw new Exception($e->getResponse()->getBody());
     }
 }
 /**
  * @param string $resource
  * @param array $arguments
  * @param string $method
  * @return string
  * @throws Exception
  */
 private function makeRequest($resource, $arguments, $method)
 {
     try {
         $options = $this->getOptions($method, $arguments);
         $response = $this->client->{$method}($this->endpoint . $resource, $options);
         $collection = new Collection(json_decode($response->getBody(), true));
         if ($collection->count() == 1) {
             return $collection->collapse();
         }
         return $collection;
     } catch (ClientException $e) {
         throw new Exception($e->getResponse()->getBody());
     } catch (RequestException $e) {
         $response = $e->getResponse();
         if ($response instanceof ResponseInterface) {
             throw new Exception($e->getResponse()->getBody());
         }
         throw new Exception($e->getMessage());
     }
 }
 public function testCollapseWithNestedCollactions()
 {
     $data = new Collection([new Collection([1, 2, 3]), new Collection([4, 5, 6])]);
     $this->assertEquals([1, 2, 3, 4, 5, 6], $data->collapse()->all());
 }