LaravelPdfOptimizer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromDisk() 0 5 1
A open() 0 12 2
1
<?php
2
3
namespace Mostafaznv\PdfOptimizer\Laravel;
4
5
use Illuminate\Http\UploadedFile;
6
use Mostafaznv\PdfOptimizer\Laravel\Concerns\Export;
7
use Mostafaznv\PdfOptimizer\Laravel\Concerns\File;
8
9
10
class LaravelPdfOptimizer
11
{
12
    private ?string $disk = null;
13
14
15
    public function fromDisk(string $disk): self
16
    {
17
        $this->disk = $disk;
18
19
        return $this;
20
    }
21
22
    public function open(UploadedFile|string $file): Export
23
    {
24
        if ($file instanceof UploadedFile) {
25
            $this->disk = null;
26
27
            $file = File::make($file->getRealPath(), $this->disk);
28
        }
29
        else {
30
            $file = File::make($file, $this->disk);
31
        }
32
33
        return new Export($file, config('pdf-optimizer.gs'));
34
    }
35
}
36