/** * FilesystemIterator::current — The current file * * @return mixed null or artray */ public function current() { $file = parent::current(); if (!$file instanceof SplFileInfo) { return null; } $real = \MUtil_File::cleanupSlashes($file->getRealPath()); // The relative file name uses the windows directory seperator convention as this // does not screw up the use of this value as a parameter $rel = \MUtil_File::cleanupSlashes(\MUtil_String::stripStringLeft($real, $this->startPath)); // Function was first implemented in PHP 5.3.6 if (method_exists($file, 'getExtension')) { $extension = $file->getExtension(); } else { $extension = pathinfo($file->getFilename(), PATHINFO_EXTENSION); } return array('fullpath' => $real, 'relpath' => $rel, 'urlpath' => str_replace(array('\\', '/'), '|', $rel), 'path' => \MUtil_File::cleanupSlashes($file->getPath()), 'filename' => $file->getFilename(), 'extension' => $extension, 'content' => \MUtil_Lazy::call('file_get_contents', $real), 'size' => $file->getSize(), 'changed' => new \MUtil_Date($file->getMTime())); }
/** * Remove nothing as both strings have no common starting characters */ public function testStripStringLeftNothing() { $result = MUtil_String::stripStringLeft('abcdef', 'xabc'); $this->assertEquals($result, 'abcdef'); }