Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
S
sidekick
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Privat - Marco Schmiedel
sidekick
Commits
9bb85d7d
Commit
9bb85d7d
authored
Apr 13, 2022
by
Marco Schmiedel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
9d037667
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
16 deletions
+77
-16
CodebeautifierCommand.php
src/Commands/CodebeautifierCommand/CodebeautifierCommand.php
+37
-16
BeautifyManager.php
src/Managers/BeautifyManager/BeautifyManager.php
+6
-0
DirectoryManager.php
src/Managers/DirectoryManager/DirectoryManager.php
+34
-0
No files found.
src/Commands/CodebeautifierCommand/CodebeautifierCommand.php
View file @
9bb85d7d
...
@@ -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: 202
1-12-23 20:30:33
| Date: 202
2-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
;
...
@@ -31,7 +32,7 @@
...
@@ -31,7 +32,7 @@
| Class "CodebeautifierCommand"
| Class "CodebeautifierCommand"
|------------------------------------------------------------------------------------------------
|------------------------------------------------------------------------------------------------
*/
*/
class
CodebeautifierCommand
extends
Command
class
CodebeautifierCommand
extends
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!'
);
|------------------------------------------------------------------------------------
| Stop the command...
return
;
*/
}
return
false
;
/*
|----------------------------------------------------------------------------------------
| Drop info for a wrong file path.
*/
$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
())
);
/*
/*
|----------------------------------------------------------------------------------------
|----------------------------------------------------------------------------------------
...
...
src/Managers/BeautifyManager/BeautifyManager.php
View file @
9bb85d7d
...
@@ -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.
...
...
src/Managers/DirectoryManager/DirectoryManager.php
0 → 100644
View file @
9bb85d7d
<?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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment