Skip to content

Commit

Permalink
Fix backup dto to pass test and pint
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoIsRecursive committed Mar 4, 2024
1 parent ec3d56e commit 3558d97
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/DataTransferObjects/BackupDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Carbon\Carbon;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Statamic\Support\Str as StatamicStr;

final readonly class BackupDto
Expand All @@ -26,7 +25,7 @@ public function __construct(
*/
public static function fromFile(string $path): self
{
$timestamp = Str::between(basename($path), '-', '.zip');
$timestamp = str(basename($path))->afterLast('-')->before('.zip')->toString();
$bytes = Storage::disk(config('backup.destination.disk'))->size($path);

return new self(
Expand All @@ -43,7 +42,7 @@ public static function fromFile(string $path): self
*/
public static function fromAbsolutePath(string $path): self
{
$timestamp = Str::between(basename($path), '-', '.zip');
$timestamp = str(basename($path))->afterLast('-')->before('.zip')->toString();
$bytes = File::size($path);

return new self(
Expand Down
4 changes: 1 addition & 3 deletions tests/Unit/BackupDtoTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

use Carbon\Carbon;
use Itiden\Backup\Contracts\Repositories\BackupRepository;
use Itiden\Backup\DataTransferObjects\BackupDto;
use Itiden\Backup\Facades\Backuper;

uses()->group('backupdto');
Expand All @@ -18,4 +16,4 @@

expect($backup->timestamp)->toBeString();
expect($backup->timestamp)->toBe((string) $fakeTime->timestamp);
});
});

0 comments on commit 3558d97

Please sign in to comment.