Hoa central
SplFileInfo.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Iterator;
38 
48 {
54  protected $_hash = null;
55 
61  protected $_relativePath = null;
62 
63 
64 
72  public function __construct($filename, $relativePath = null)
73  {
74  parent::__construct($filename);
75 
76  if (-1 !== $mtime = $this->getMTime()) {
77  $this->_hash = md5($this->getPathname() . $mtime);
78  }
79 
80  $this->_relativePath = $relativePath;
81 
82  return;
83  }
84 
90  public function getHash()
91  {
92  return $this->_hash;
93  }
94 
100  public function getMTime()
101  {
102  try {
103  return parent::getMTime();
104  } catch (\RuntimeException $e) {
105  return -1;
106  }
107  }
108 
115  public function setRelativePath($relativePath)
116  {
117  $old = $this->_relativePath;
118  $this->_relativePath = $relativePath;
119 
120  return $old;
121  }
122 
128  public function getRelativePath()
129  {
130  return $this->_relativePath;
131  }
132 
138  public function getRelativePathname()
139  {
140  if (null === $relative = $this->getRelativePath()) {
141  return $this->getPathname();
142  }
143 
144  return substr($this->getPathname(), strlen($relative));
145  }
146 }
setRelativePath($relativePath)
__construct($filename, $relativePath=null)
Definition: SplFileInfo.php:72