/**
  * {@inheritdoc}
  */
 public function validate()
 {
     $path = Path::normalize($this->value);
     $test = $this->isDir === true ? Dir::isWritable($path) : File::isWritable($path);
     if ($test === true) {
         $this->value = $path;
         return true;
     }
     $this->message = $test;
     return false;
 }
 /**
  * {@inheritdoc}
  * 
  * @todo the call to setMessage will override custom message if one is set
  */
 public function validate()
 {
     $path = Path::normalize($this->value);
     $test = Path::test($path, $this->bitmask);
     if ($test === true) {
         $this->value = $path;
         return true;
     } else {
         $this->setMessage($test);
         return false;
     }
 }
Exemple #3
0
 /**
  * A convience method to create a filesystem iterator
  * 
  * @param string $dir An absolute path to the directory to search
  * @param integer $options A bitmask of iterator options
  * @return DirectoryIterator|RecursiveIteratorIterator
  */
 public static function getIterator($dir, $options = 0)
 {
     if (is_string($dir) === false) {
         throw new InvalidArgumentException("invalid value provided for 'dir'; " . "expecting an absolute directory path as string");
     } else {
         if (($test = Dir::isReadable($dir)) !== true) {
             throw new InvalidArgumentException("invalid value provided for 'dir'; {$test}");
         } else {
             if (!is_int($options)) {
                 throw new InvalidArgumentException("invalid value provided for 'options'; " . "expecting an integer");
             }
         }
     }
     return self::createIterator(Path::normalize($dir), $options);
 }