• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

conedevelopment / root / 18585608047

17 Oct 2025 07:22AM UTC coverage: 76.113% (+0.1%) from 75.974%
18585608047

push

github

iamgergo
wip

3384 of 4446 relevant lines covered (76.11%)

34.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/src/Jobs/MoveFile.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Cone\Root\Jobs;
6

7
use Cone\Root\Models\Medium;
8
use Illuminate\Bus\Queueable;
9
use Illuminate\Contracts\Queue\ShouldQueue;
10
use Illuminate\Foundation\Bus\Dispatchable;
11
use Illuminate\Http\File as Stream;
12
use Illuminate\Queue\InteractsWithQueue;
13
use Illuminate\Queue\SerializesModels;
14
use Illuminate\Support\Facades\File;
15
use Illuminate\Support\Facades\Storage;
16
use Throwable;
17

18
class MoveFile implements ShouldQueue
19
{
20
    use Dispatchable;
21
    use InteractsWithQueue;
22
    use Queueable;
23
    use SerializesModels;
24

25
    /**
26
     * Delete the job if its models no longer exist.
27
     *
28
     * @var bool
29
     */
30
    public $deleteWhenMissingModels = true;
31

32
    /**
33
     * Create a new job instance.
34
     */
35
    public function __construct(
2✔
36
        public readonly Medium $medium,
37
        public readonly string $path,
38
        public readonly bool $preserve = true
39
    ) {
40
        //
41
    }
2✔
42

43
    /**
44
     * Execute the job.
45
     */
46
    public function handle(): void
1✔
47
    {
48
        $directory = dirname($this->medium->getPath());
1✔
49

50
        Storage::disk($this->medium->disk)->makeDirectory($directory);
1✔
51

52
        Storage::disk($this->medium->disk)->putFileAs(
1✔
53
            $directory, new Stream($this->path), basename($this->medium->getPath())
1✔
54
        );
1✔
55

56
        if (! $this->preserve && ! filter_var($this->path, FILTER_VALIDATE_URL)) {
1✔
57
            File::delete($this->path);
1✔
58
        }
59
    }
60

61
    /**
62
     * Handle a job failure.
63
     */
64
    public function failed(Throwable $exception): void
×
65
    {
66
        $this->medium->delete();
×
67
    }
68
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc