<?php
namespace App\Libraries;
/**
* Class FileHandler
*
* @package App\Libraries
*/
class FileHandler
{
/**
* Class properties go here.
* -------------------------------------------------------------------
* public, private, protected, static and const.
*/
/**
* __construct ()
* -------------------------------------------------------------------
*
* Class Constructor
*
* NOTE: Not needed if not setting values or extending a Class.
*
*/
public function __construct()
{
}
// -------------------------------------------------------------------
/**
* renameFile ()
* -------------------------------------------------------------------
*
* renames $oldFilename to path $newFilename
*
* The rename method returns true on success or false on error.
*
* @param string $oldFilename
* @param string $newFilename
* @return bool
*/
public function renameFile(string $oldFilename = '', string $newFilename = '') : bool
{
if (empty($oldFilename) or empty($newFilename))
{
return false;
}
else
{
return rename($oldFilename, $newFilename);
}
}
// -------------------------------------------------------------------
/**
* copyFile ()
* -------------------------------------------------------------------
*
* copies $oldFilename to path $newFilename
*
* The copy method returns true on success or false on error.
*
* @param string $oldFilename
* @param string $newFilename
* @return bool
*/
public function copyFile(string $oldFilename = '', string $newFilename = '') : bool
{
if (empty($oldFilename) or empty($newFilename))
{
return false;
}
else
{
return copy($oldFilename, $newFilename);
}
}
// -------------------------------------------------------------------
} // End of FileHandler Library Class.
/**
* -----------------------------------------------------------------------
* Filename: FileHandler.php
* Location: ./app/Libraries/FileHandler.php
* -----------------------------------------------------------------------
*/