filters = $filters; } public function build() { $prefix = ""; $suffix = ''; $xml = collect($this->filters)->map(function ($items) { return $this->buildEntry($items); })->implode(''); return $prefix . $xml . $suffix; } /** * @param array $items * * @return string */ private function buildEntry(array $items) { $entry = collect($items)->map(function ($value, $key) { return $this->buildProperty($value, $key); })->implode(''); return "{$entry}"; } /** * Build XML for a property. * * @param string $value * @param string $key * * @return string */ private function buildProperty($value, $key) { if ($key == 'from') { $value = collect($value)->implode('|'); } return ""; } }