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

RonasIT / laravel-helpers / 12489544920

25 Dec 2024 04:53AM UTC coverage: 78.401% (+0.02%) from 78.385%
12489544920

Pull #168

github

web-flow
Merge a36445178 into 338a94856
Pull Request #168: #140 global export mode not affect for email testing

2 of 2 new or added lines in 1 file covered. (100.0%)

1020 of 1301 relevant lines covered (78.4%)

11.92 hits per line

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

0.0
/src/Traits/FilesUploadTrait.php
1
<?php
2

3
namespace RonasIT\Support\Traits;
4

5
use Illuminate\Http\UploadedFile;
6
use Illuminate\Support\Facades\Storage;
7

8
trait FilesUploadTrait
9
{
10
    protected function saveFile($fileName, $content): string
11
    {
12
        $preparedName = $this->generateName($fileName);
×
13

14
        Storage::put($preparedName, $content);
×
15

16
        return $preparedName;
×
17
    }
18

19
    protected function checkUploadedFile($path): bool
20
    {
21
        return Storage::exists($path);
×
22
    }
23

24
    protected function getFileForUploading($path)
25
    {
26
        return new UploadedFile($path, $this->generateName($path));
×
27
    }
28

29
    protected function clearUploadedFilesFolder()
30
    {
31
        $files = Storage::allFiles();
×
32

33
        foreach ($files as $file) {
×
34
            Storage::delete($file);
×
35
        }
36
    }
37

38
    protected function generateName($path): string
39
    {
40
        $name = basename($path);
×
41
        $explodedName = explode('.', $name);
×
42
        $extension = array_pop($explodedName);
×
43
        $hash = md5(uniqid());
×
44
        $timestamp = str_replace(['.', ' '], '_', microtime());
×
45

46
        return "{$timestamp}_{$hash}.{$extension}";
×
47
    }
48

49
    public function getFilePathFromUrl($url)
50
    {
51
        $explodedUrl = explode('/', $url);
×
52

53
        return last($explodedUrl);
×
54
    }
55
}
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