Skip to content

Commit

Permalink
Laravel 9 support
Browse files Browse the repository at this point in the history
  • Loading branch information
hedii committed Mar 6, 2022
1 parent bb21210 commit 9818710
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '7.3', '7.4', '8.0', '8.1' ]
php-versions: [ '8.0', '8.1' ]
name: Testing on PHP ${{ matrix.php-versions }}
steps:
- name: Checkout
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
"source": "https://github.com/hedii/artisan-log-cleaner"
},
"require": {
"php": "^7.3|^8.0",
"illuminate/console": "^8.12",
"illuminate/filesystem": "^8.12",
"illuminate/support": "^8.12"
"php": "^8.0",
"illuminate/console": "^9.0",
"illuminate/filesystem": "^9.0",
"illuminate/support": "^9.0"
},
"require-dev": {
"orchestra/testbench": "^6.0"
"orchestra/testbench": "^7.0"
},
"autoload": {
"psr-4": {
Expand Down
18 changes: 2 additions & 16 deletions src/ClearLogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,14 @@ class ClearLogs extends Command
*/
protected $description = 'Remove every log files in the log directory';

/**
* A filesystem instance.
*
* @var \Illuminate\Filesystem\Filesystem
*/
private $disk;

/**
* Create a new command instance.
*
* @param \Illuminate\Filesystem\Filesystem $disk
*/
public function __construct(Filesystem $disk)
public function __construct(private Filesystem $disk)
{
parent::__construct();

$this->disk = $disk;
}

/**
Expand All @@ -65,21 +56,16 @@ public function handle(): void

/**
* Get a collection of log files sorted by their last modification date.
*
* @return \Illuminate\Support\Collection
*/
private function getLogFiles(): Collection
{
return collect(
return Collection::make(
$this->disk->allFiles(storage_path('logs'))
)->sortBy('mtime');
}

/**
* Delete the given files.
*
* @param \Illuminate\Support\Collection $files
* @return int
*/
private function delete(Collection $files): int
{
Expand Down
10 changes: 3 additions & 7 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
namespace Hedii\ArtisanLogCleaner\Tests;

use Hedii\ArtisanLogCleaner\ArtisanLogCleanerServiceProvider;
use Illuminate\Foundation\Application;
use Orchestra\Testbench\TestCase as Orchestra;

class TestCase extends Orchestra
{
/**
* The log directory path.
*
* @var string
*/
protected $logDirectory;
protected string $logDirectory;

/**
* Executed before each test.
Expand Down Expand Up @@ -40,7 +39,6 @@ public function tearDown(): void
* Load the command service provider.
*
* @param \Illuminate\Foundation\Application $app
* @return array
*/
protected function getPackageProviders($app): array
{
Expand All @@ -49,10 +47,8 @@ protected function getPackageProviders($app): array

/**
* Create fake log files in the test temporary directory.
*
* @param array|string $files
*/
protected function createLogFile($files): void
protected function createLogFile(array|string $files): void
{
foreach ((array) $files as $file) {
touch($this->logDirectory . '/' . $file);
Expand Down

0 comments on commit 9818710

Please sign in to comment.