Hoa central
Directory.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Iterator;
38 
47 class Directory extends \DirectoryIterator
48 {
54  protected $_splFileInfoClass = null;
55 
61  protected $_relativePath = null;
62 
63 
64 
73  public function __construct($path, $splFileInfoClass = null)
74  {
75  $this->_splFileInfoClass = $splFileInfoClass;
76  parent::__construct($path);
77  $this->setRelativePath($path);
78 
79  return;
80  }
81 
88  public function current()
89  {
90  $out = parent::current();
91 
92  if (null !== $this->_splFileInfoClass &&
93  $out instanceof \SplFileInfo) {
94  $out->setInfoClass($this->_splFileInfoClass);
95  $out = $out->getFileInfo();
96 
97  if ($out instanceof \Hoa\Iterator\SplFileInfo) {
98  $out->setRelativePath($this->getRelativePath());
99  }
100  }
101 
102  return $out;
103  }
104 
111  protected function setRelativePath($path)
112  {
113  $old = $this->_relativePath;
114  $this->_relativePath = $path;
115 
116  return $old;
117  }
118 
124  public function getRelativePath()
125  {
126  return $this->_relativePath;
127  }
128 }
__construct($path, $splFileInfoClass=null)
Definition: Directory.php:73