original_string: private function searchInPath(FileSystem\Iterator\IteratorAggregate $iterator, $path, FileSystem\Directory $parent = null, $depth = 0)
      {
          // when exists.
          if (file_exists($path)) {
              if(is_dir($path)) {
                  $dir = new FileSystem\Directory($path);
                  if ($parent) $dir->setParent($parent);
                  if ($this->validate($dir)) $iterator->add($dir);
                  if ($this->recursive || $depth < 1) {
                      $this->searchInPath($iterator, "{$dir}/*", $dir, $depth + 1);
                  }
              } else {
                  $file = new FileSystem\File($path);
                  if ($parent) $file->setParent($parent);
                  if ($this->validate($file)) $iterator->add($file);
              }
          }
          // when not exists, then glob.
          else {
              foreach (glob($path) as $file) {
                  $this->searchInPath($iterator, $file, $parent, $depth);
              }
          }
      }
code: private function searchInPath(FileSystem\Iterator\IteratorAggregate $iterator, $path, FileSystem\Directory $parent = null, $depth = 0)
      {
          // when exists.
          if (file_exists($path)) {
              if(is_dir($path)) {
                  $dir = new FileSystem\Directory($path);
                  if ($parent) $dir->setParent($parent);
                  if ($this->validate($dir)) $iterator->add($dir);
                  if ($this->recursive || $depth < 1) {
                      $this->searchInPath($iterator, "{$dir}/*", $dir, $depth + 1);
                  }
              } else {
                  $file = new FileSystem\File($path);
                  if ($parent) $file->setParent($parent);
                  if ($this->validate($file)) $iterator->add($file);
              }
          }
          // when not exists, then glob.
          else {
              foreach (glob($path) as $file) {
                  $this->searchInPath($iterator, $file, $parent, $depth);
              }
          }
      }
code_tokens: private function searchInPath ( FileSystem \ Iterator \ IteratorAggregate $ iterator , $ path , FileSystem \ Directory $ parent = null , $ depth = 0 ) { // when exists. if ( file_exists ( $ path ) ) { if ( is_dir ( $ path ) ) { $ dir = new FileSystem \ Directory ( $ path ) ; if ( $ parent ) $ dir -> setParent ( $ parent ) ; if ( $ this -> validate ( $ dir ) ) $ iterator -> add ( $ dir ) ; if ( $ this -> recursive || $ depth < 1 ) { $ this -> searchInPath ( $ iterator , "{$dir}/*" , $ dir , $ depth + 1 ) ; } } else { $ file = new FileSystem \ File ( $ path ) ; if ( $ parent ) $ file -> setParent ( $ parent ) ; if ( $ this -> validate ( $ file ) ) $ iterator -> add ( $ file ) ; } } // when not exists, then glob. else { foreach ( glob ( $ path ) as $ file ) { $ this -> searchInPath ( $ iterator , $ file , $ parent , $ depth ) ; } } }
docstring: search files in target path.
  
  @param   Samurai\Samurai\Component\FileSystem\Iterator\IteratorAggregate $iterator
  @param   string  $path
  @param   Samurai\Samurai\Component\FileSystem\Directory  $parent
  @param   int     $depth
  @return  array
docstring_tokens: search files in target path .