protected function export() { $cols = func_get_args(); // add cols if (method_exists($this, 'hasRef') && $this->hasRef()) { $cols = array_merge(['$ref'], $cols); } // flatten array $fields = []; array_walk_recursive($cols, function ($a) use(&$fields) { $fields[] = $a; }); $out = []; $refl = new \ReflectionClass(get_class($this)); foreach ($fields as $field) { if ($field == 'tags') { $val = $this->exportTags(); } else { $prop = $refl->getProperty($field == '$ref' ? 'ref' : $field); $prop->setAccessible(true); $val = $prop->getValue($this); if ($val instanceof Collection) { $val = CollectionUtils::toArrayRecursive($val); } else { if (is_object($val) && method_exists($val, 'toArray')) { $val = $val->toArray(); } } } if ($field == 'required' && is_bool($val) || !empty($val)) { $out[$field] = $val; } } if (method_exists($this, 'getExtensions')) { $out = array_merge($out, $this->getExtensions()->toArray()); } return $out; }
public function toArray() { return array_merge(CollectionUtils::toArrayRecursive($this->operations), CollectionUtils::toArrayRecursive($this->getExtensions())); }
public function testToRecursiveArray() { $data = ['a' => 'b', 'c' => [1, ['x' => 'y'], 4], 'd' => ['x' => 'y', 'z' => 'zz']]; $collection = CollectionUtils::fromCollection($data); $this->assertEquals($data, CollectionUtils::toArrayRecursive($collection)); }
public function toArray() { return CollectionUtils::toArrayRecursive($this->headers); }
public function toArray() { return CollectionUtils::toArrayRecursive($this->definitions); }
public function toArray() { return CollectionUtils::toArrayRecursive($this->schemes); }
public function toArray() { $responses = clone $this->responses; $responses->setAll($this->getExtensions()); return CollectionUtils::toArrayRecursive($responses); }