Exemplo n.º 1
0
 /**
  * @covers Corgi\File\Helpers\FileSystemHelper::isReadableDirectory
  */
 public function testIsReadableDirectory()
 {
     $this->assertBool(FileSystemHelper::isReadableDirectory());
 }
Exemplo n.º 2
0
 /**
  * Returns directory contents as an array of FileSystemNode objects
  * @return array
  * @throws NotReadableException
  */
 public function toArray()
 {
     if (!FileSystemHelper::isReadableDirectory($this->directory)) {
         throw new NotReadableException($this->directory);
     }
     $contents = new \stdClass();
     $contents->data = [];
     /**
      * @param \SplFileInfo $currentItem
      */
     $closure = function ($currentItem) use($contents) {
         $contents->data[] = $currentItem->isDir() ? new Directory($currentItem->getRealPath()) : new File($currentItem->getRealPath());
     };
     $this->getDirectory()->iterate($closure, \RecursiveIteratorIterator::CHILD_FIRST);
     return $contents->data;
 }