/** * Read and parse file */ public function parse() { parent::parse(); if (is_null($this->name)) { throw $this->exception('No Title in header'); } if (is_null($this->description)) { throw $this->exception('No Description in header'); } if (is_null($this->categories)) { throw $this->exception('No Categories in header'); } // Clean up category slugs $array = []; foreach (explode(',', $this->categories) as $item) { $item = trim($item); if ($item === '-') { continue; } if ($item === '') { throw $this->exception("Categories has empty item"); } $litem = strtolower($item); if (array_key_exists($litem, $array)) { throw $this->exception("Categories '{$item}' in multiple times"); } $array[$litem] = $item; } $this->my_cats = array_values($array); }
/** * Read and parse file */ public function parse() { parent::parse(); if (is_null($this->name)) { throw $this->exception('No Name in header'); } if (is_null($this->description)) { throw $this->exception('No Description in header'); } // Load any recipes $path = str_replace('00-about', '*', $this->filename); $this->recipes = array(); $files = File::glob($path); foreach ($files as $file) { $name = basename($file); if ($name !== '00-about.md') { $this->recipes[] = new RecipeFile($file); } } if (count($this->recipes) == 0) { throw $this->exception('No recipes for category'); } }