Completed
Push — master ( a6dd06...dfef89 )
by Freek
01:14
created

MediaCollection   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 6
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 6
cbo 0
dl 0
loc 80
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A create() 0 4 1
A useDisk() 0 6 1
A acceptsFile() 0 6 1
A singleFile() 0 6 1
A registerMediaConversions() 0 4 1
A useFallbackUrl() 0 6 1
A useFallbackPath() 0 6 1
1
<?php
2
3
namespace Spatie\MediaLibrary\MediaCollection;
4
5
class MediaCollection
6
{
7
    /** @var string */
8
    public $name = '';
9
10
    /** @var string */
11
    public $diskName = '';
12
13
    /** @var callable */
14
    public $mediaConversionRegistrations;
15
16
    /** @var callable */
17
    public $acceptsFile;
18
19
    /** @var bool */
20
    public $singleFile = false;
21
22
    /** @var string */
23
    public $fallbackUrl = '';
24
25
    /** @var string */
26
    public $fallbackPath = '';
27
28
    public function __construct(string $name)
29
    {
30
        $this->name = $name;
31
32
        $this->mediaConversionRegistrations = function () {
33
        };
34
35
        $this->acceptsFile = function () {
36
            return true;
37
        };
38
    }
39
40
    public static function create($name)
41
    {
42
        return new static($name);
43
    }
44
45
    public function useDisk(string $diskName): self
46
    {
47
        $this->diskName = $diskName;
48
49
        return $this;
50
    }
51
52
    public function acceptsFile(callable $acceptsFile): self
53
    {
54
        $this->acceptsFile = $acceptsFile;
55
56
        return $this;
57
    }
58
59
    public function singleFile(): self
60
    {
61
        $this->singleFile = true;
62
63
        return $this;
64
    }
65
66
    public function registerMediaConversions(callable $mediaConversionRegistrations)
67
    {
68
        $this->mediaConversionRegistrations = $mediaConversionRegistrations;
69
    }
70
71
    public function useFallbackUrl(string $url): self
72
    {
73
        $this->fallbackUrl = $url;
74
75
        return $this;
76
    }
77
78
    public function useFallbackPath(string $path): self
79
    {
80
        $this->fallbackPath = $path;
81
82
        return $this;
83
    }
84
}
85