Ejemplo n.º 1
0
 /**
  * Set the namespace directory.
  *
  * @param Directory|string $dir The namespace directory.
  *
  * @throws CarbonException Throws if the directory is invalid.
  */
 public function setDirectory($dir)
 {
     // Parse the directory
     if (($dir = DirectoryHelper::asDirectory($dir, null)) === null) {
         throw new CarbonException("Failed to set the directory of the file loader, the directory is invalid.");
     }
     // Set the directory instance
     $this->dir = $dir;
 }
 /**
  * Set the directory to scan
  *
  * @param Directory|string $dir Directory instance or a directory path as string.
  *
  * @return bool True on success, false on failure.
  */
 public function setDirectory($dir)
 {
     // Convert $dir into a Directory instance, return false on failure
     if (($dir = DirectoryHelper::asDirectory($dir)) === null) {
         return false;
     }
     // Set the directory
     $this->dir = $dir;
     // Set the directory in the directory handler if it's initialized, return the result
     if ($this->handler !== null) {
         return $this->handler->setDirectory($dir);
     }
     return true;
 }
Ejemplo n.º 3
0
 /**
  * Get the Directory instance from a FileSystemObject instance or the path a string from a directory.
  * If the filesystem object is an existing file or symbolic link, null will be returned.
  * The directory or directory path has to be valid.
  *
  * @param FilesystemObject|string $dir Filesystem object instance or the path of a directory as a string.
  *
  * @return Directory|null The directory as a Directory instance.
  * Or null if the directory couldn't be cast to a Directory instance.
  */
 public static function asDirectory($dir)
 {
     return DirectoryHelper::asDirectory($dir);
 }