for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/**
* RenameFile.php
*/
namespace HDNET\Importr\Feature;
use HDNET\Importr\Domain\Model\Import;
use HDNET\Importr\Service\FileService;
use HDNET\Importr\Service\ManagerInterface;
* Class RenameFile
class RenameFile
{
* @var FileService
protected $fileService;
* RenameFile constructor.
*
* @param FileService $fileService
public function __construct(FileService $fileService)
$this->fileService = $fileService;
}
public static function enable()
FeatureRegistry::enable('afterImport');
* To rename a file from the importr you
* have to use the "rename: 1" statement in
* your configuration. The file will be
* prefixed with the current (human readable)
* timestamp.
* Caution: after this method, the file is moved
* you should only use this in the before
* configuration if you are fully aware of it!
* @param ManagerInterface $manager
* @param Import $import
public function execute(ManagerInterface $manager, Import $import)
$manager
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
$configuration = $import->getStrategy()
->getConfiguration();
if (isset($configuration['after']['rename'])) {
$oldFileName = $this->fileService->getFileAbsFileName($import->getFilepath());
$info = \pathinfo($oldFileName);
$newFileName = $info['dirname'] . DIRECTORY_SEPARATOR . \date('YmdHis') . '_' . $info['basename'];
\rename($oldFileName, $newFileName);
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.