/** * Read hosts file if it exist in $filePath. * If file exist return your content, if not return exception message. * * @return string */ public function getContent() { try { return $this->filesystem->get($this->filePath); } catch (FileNotFoundException $e) { return $e->getMessage(); } }
/** * Get content in template file * Using name of the host search template file. * * @param $hostName * * @return string */ protected function getTemplateContent($hostName) { $files = $this->filesystem->files($this->templateDir); $content = ''; array_walk($files, function ($file) use($hostName, &$content) { if (preg_match('/' . $hostName . '/', $file)) { $content = $this->filesystem->get($file); } }); return $content; }