public static function getFilename($filepath) { $explode_filepath = explode('/', $filepath); return \Library\Helper\File::getHumanReadableFilename(end($explode_filepath)); }
/** * Get a formated filename * * @param string $filename The filename to format * @param boolean $lowercase Should we return the name un lowercase (FALSE by default) * @param string $delimiter The delimiter used for special chars substitution * @param bool $return Return/Echo flag (default is to echo result) * @return mixed The result of the `_echo` function (string or bool) * @see _echo() * @see Library\Helper\File::formatFilename() */ function _filename($filename, $lowercase = false, $delimiter = '-', $return = false) { return _echo(Helper\File::formatFilename($filename, $lowercase, $delimiter), $return); }
echo '=> ' . var_export(Library\Helper\File::formatFilename($str), 1); ?> </pre> <h4 id="dirhelper">Library\Helper\Directory</h4> <pre class="code" data-language="php"> <?php $logs = array(); $dir = __DIR__ . '/tmp/tmp_tmp'; echo '$logs = array();' . "\n"; echo '$dir = __DIR__."/tmp/tmp_tmp";' . "\n"; \Library\Helper\Directory::ensureExists($dir); \Library\Helper\File::touch($dir . '/test1'); \Library\Helper\File::touch($dir . '/test2'); \Library\Helper\File::touch($dir . '/test/test1'); \Library\Helper\File::touch($dir . '/test/test2'); \Library\Helper\Directory::chmod($dir, 777, true, 766, $logs); \Library\Helper\Directory::remove($dir, $logs); echo "\n"; echo '\\Library\\Helper\\Directory::ensureExists($dir);' . "\n"; echo '\\Library\\Helper\\File::touch($dir."/test1");' . "\n"; echo '\\Library\\Helper\\File::touch($dir."/test2");' . "\n"; echo '\\Library\\Helper\\File::touch($dir."/test/test1");' . "\n"; echo '\\Library\\Helper\\File::touch($dir."/test/test2");' . "\n"; echo '\\Library\\Helper\\Directory::chmod($dir, 777, true, 766, $logs);' . "\n"; echo '\\Library\\Helper\\Directory::remove($dir, $logs);' . "\n"; echo "\n"; echo 'var_export($logs);' . "\n"; var_export($logs); ?> </pre>
/** * @covers ../../../src/Library/Helper/Directory::remove() */ public function test_remove() { $this->checkNoArg('remove'); \Library\Helper\File::touch(self::$tmp_file); $logs = array(); $this->assertTrue(\Library\Helper\Directory::remove(self::$tmp_dir, $logs)); $this->assertEmpty($logs); }
/** * @covers ../../../src/Library/Helper/File::write() */ public function test_write() { $this->checkNoArg('remove'); \Library\Helper\Directory::ensureExists(self::$tmp_dir); \Library\Helper\File::touch(self::$tmp_file); $logs = array(); $this->assertTrue(\Library\Helper\File::write(self::$tmp_file, $this->lorem_ipsum)); $this->assertEmpty($logs); $ctt = trim(file_get_contents(self::$tmp_file)); $this->assertEquals($this->lorem_ipsum, $ctt); }
public function generate() { $this->_init(); $logs = array(); // loop over each characters letter for ($j = 0; $j < count($this->characters); $j++) { $l = $this->characters[$j]; // loop to create string in length [min;max] for ($i = $this->min_length; $i <= $this->max_length; $i++) { $str = str_pad($l, $i, $l); FileHelper::write($this->rainbow_file, $this->doProcess($str, $this->closure) . "\t" . $str . "\n", 'a+', true, $logs); } } return $logs; }