Commit 9bb85d7d authored by Marco Schmiedel's avatar Marco Schmiedel

fix

parent 9d037667
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
| sidekick package. | sidekick package.
| |
| Author: Marco Schmiedel <marco.schmiedel@itmax.email> | Author: Marco Schmiedel <marco.schmiedel@itmax.email>
| Date: 2021-12-23 20:30:33 | Date: 2022-04-13 07:39:40
| |
*/ */
namespace Ceetrox\Commands\CodebeautifierCommand; namespace Ceetrox\Commands\CodebeautifierCommand;
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*/ */
use Ceetrox\Managers\TerminalManager\TerminalManager; use Ceetrox\Managers\TerminalManager\TerminalManager;
use Ceetrox\Managers\BeautifyManager\BeautifyManager; use Ceetrox\Managers\BeautifyManager\BeautifyManager;
use Ceetrox\Managers\DirectoryManager\DirectoryManager;
use Illuminate\Console\Command; use Illuminate\Console\Command;
...@@ -59,32 +60,52 @@ ...@@ -59,32 +60,52 @@
|---------------------------------------------------------------------------------------- |----------------------------------------------------------------------------------------
| Try to get the filepath from the command line argument. | Try to get the filepath from the command line argument.
*/ */
$file = $this->argument('path'); $path = $this->argument('path');
/* /*
|---------------------------------------------------------------------------------------- |----------------------------------------------------------------------------------------
| Check if the given file exists. | Check if the given file exists.
*/ */
if(!file_exists($file)) if(file_exists($path) and !is_dir($path))
{ {
/* $this->singleCleaning($path);
|------------------------------------------------------------------------------------
| Drop error for a wrong file path. return;
*/ }
$file = $this->error('Please enter a valid path to a php class!'); elseif(!is_dir($path))
{
$this->error('Please enter a valid path!');
return;
}
/* /*
|------------------------------------------------------------------------------------ |----------------------------------------------------------------------------------------
| Stop the command... | Drop info for a wrong file path.
*/ */
return false; $this->error($path);
if ($this->confirm('This is not a valid php file. Do you want to clean the whole path?'))
{
dd( DirectoryManager::getFilesWithFiletypeForDirectory($path, 'php') );
} }
}
/*
|--------------------------------------------------------------------------------------------
| Method "singleCleaning"
|--------------------------------------------------------------------------------------------
*/
private function singleCleaning($file)
{
/* /*
|---------------------------------------------------------------------------------------- |----------------------------------------------------------------------------------------
| Copy a backup to the vendor folder. | Copy a backup to the vendor folder.
*/ */
copy( $file, __DIR__.'/BACKUP_'.time() ); copy( $file, __DIR__.'/BACKUP_'.time().md5(microtime()) );
/* /*
|---------------------------------------------------------------------------------------- |----------------------------------------------------------------------------------------
......
...@@ -354,6 +354,12 @@ ...@@ -354,6 +354,12 @@
*/ */
$classes = $this->matchBetweenTwoPatterns($this->content, $openPattern, $closePattern); $classes = $this->matchBetweenTwoPatterns($this->content, $openPattern, $closePattern);
// Exit when now class was found
if($classes == false)
{
exit();
}
/* /*
|---------------------------------------------------------------------------------------- |----------------------------------------------------------------------------------------
| loop detected clases. | loop detected clases.
......
<?php
namespace Ceetrox\Managers\DirectoryManager;
class DirectoryManager
{
static function getFilesWithFiletypeForDirectory($directory, $type)
{
$files = glob($directory . '/*');
$data = array();
foreach ($files as $file) {
if (is_dir($file)) {
$data = array_merge($data, self::getFilesWithFiletypeForDirectory($file, $type));
} elseif (substr($file,-4) == '.'.$type) {
$data[] = $file;
}
}
return $data;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment