config = new Config($config); } public function toArray(): array { if ($this->config->has('key')) { $key = Key::sanitize($this->config->get('key')); } else { $key = Key::sanitize($this->config->get('title')); } if (!$this->config->has('style')) { $this->config->set('style', 'seamless'); } $this->config->set('fields', array_map(function ($field) use ($key) { $field->setParentKey($key); return $field->toArray(); }, $this->config->get('fields'))); $this->config->set('location', array_map(function ($location) { return $location->toArray(); }, $this->config->get('location'))); $this->config->set('key', Key::generate($key, 'group')); return $this->config->all(); } }