/**
  * Finds all the languages
  *
  * @throws \Exception
  */
 private function findLanguages()
 {
     $dir = Utils::getLangDirectory();
     if (!file_exists($dir)) {
         throw new \Exception('Cannot find the laravel language directory: ' . $dir);
     }
     foreach (new \DirectoryIterator($dir) as $dir) {
         if (!$dir->isDot() && $dir->isDir()) {
             $this->push((string) $dir);
         }
     }
 }
 public function findNamespaces(Languages $languages)
 {
     $languages->each(function ($lang) {
         $dir = Utils::getLangDirectory($lang);
         if (!file_exists($dir)) {
             throw new \Exception('Cannot read directory for language ' . $lang);
         }
         foreach (new \DirectoryIterator($dir) as $file) {
             if ($file->isFile()) {
                 $basename = $file->getBasename('.php');
                 if (!$this->contains($basename)) {
                     $this->push($basename);
                 }
             }
         }
     });
     return $this;
 }