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

conedevelopment / root / 15084089635

17 May 2025 10:00AM UTC coverage: 77.93% (+0.04%) from 77.891%
15084089635

push

github

web-flow
Modernize back-end.yml (#240)

3291 of 4223 relevant lines covered (77.93%)

36.04 hits per line

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

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

3
namespace Cone\Root\Jobs;
4

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

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

23
    /**
24
     * The medium instance.
25
     */
26
    public Medium $medium;
27

28
    /**
29
     * The path to the file.
30
     */
31
    public string $path;
32

33
    /**
34
     * Indicates if the original file should be preserved.
35
     */
36
    public bool $preserve = true;
37

38
    /**
39
     * Delete the job if its models no longer exist.
40
     *
41
     * @var bool
42
     */
43
    public $deleteWhenMissingModels = true;
44

45
    /**
46
     * Create a new job instance.
47
     */
48
    public function __construct(Medium $medium, string $path, bool $preserve = true)
2✔
49
    {
50
        $this->path = $path;
2✔
51
        $this->medium = $medium;
2✔
52
        $this->preserve = $preserve;
2✔
53
    }
54

55
    /**
56
     * Execute the job.
57
     */
58
    public function handle(): void
1✔
59
    {
60
        $directory = dirname($this->medium->getPath());
1✔
61

62
        Storage::disk($this->medium->disk)->makeDirectory($directory);
1✔
63

64
        Storage::disk($this->medium->disk)->putFileAs(
1✔
65
            $directory, new Stream($this->path), basename($this->medium->getPath())
1✔
66
        );
1✔
67

68
        if (! $this->preserve && ! filter_var($this->path, FILTER_VALIDATE_URL)) {
1✔
69
            File::delete($this->path);
1✔
70
        }
71
    }
72

73
    /**
74
     * Handle a job failure.
75
     */
76
    public function failed(Throwable $exception): void
×
77
    {
78
        $this->medium->delete();
×
79
    }
80
}
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