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

plank / laravel-mediable / 29219995787

13 Jul 2026 02:40AM UTC coverage: 93.691% (-0.6%) from 94.27%
29219995787

Pull #391

github

frasmage
add 7.x upgrade instructions
Pull Request #391: 7.x

187 of 211 new or added lines in 8 files covered. (88.63%)

1 existing line in 1 file now uncovered.

1589 of 1696 relevant lines covered (93.69%)

162.64 hits per line

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

95.45
/src/MediaUploaderConfiguration.php
1
<?php
2

3
namespace Plank\Mediable;
4

5
use Plank\Mediable\Enum\OnDuplicateBehaviour;
6
use Plank\Mediable\FileSanitizers\SanitizerInterface;
7

8
class MediaUploaderConfiguration
9
{
10
    /**
11
     * @var array<string, array{mime_types:array<string>, extensions:array<string>}>
12
     */
13
    public array $definedAggregateTypes;
14

15
    /**
16
     * @var list<string>
17
     */
18
    public array $allowedAggregateTypes;
19

20
    public bool $allowUnrecognizedTypes;
21

22
    public bool $strictTypeChecking;
23
    public array $allowedExtensions;
24
    public array $forbiddenExtensions;
25

26
    public array $allowedMimeTypes;
27
    public array $forbiddenMimeTypes;
28
    public bool $preferClientMimeType;
29
    public int $maxUploadSize;
30

31
    /**
32
     * File hashes to validate the uploaded file against.
33
     * The key is the hash algorithm (e.g. "md5", "sha256") and the value is the expected hash value.
34
     * @var array<string, string>
35
     */
36
    public array $expectedHashes = [];
37

38
    /**
39
     * @var list<string>
40
     */
41
    public array $allowedDisks;
42
    public string $destinationDisk;
43
    public string $defaultDisk;
44

45
    /**
46
     * Path relative to the filesystem disk root where the file should be stored. Can include subdirectories, e.g. "images/uploads"
47
     */
48
    public string $destinationDirectory;
49

50
    /**
51
     * Filename to use for the stored file.
52
     * @var string|null
53
     */
54
    public ?string $destinationFilename = null;
55

56
    /**
57
     * Hash algorithm to use for generating the filename.
58
     * If set, the filename will be generated as a hash of the file contents using the specified algorithm (e.g. "md5", "sha256").
59
     * If null, the original filename or the value of $destinationFilename will be used.
60
     * @var string|null
61
     */
62
    public ?string $hashFilenameAlgorithm = null;
63

64
    /**
65
     * Alternative text to associate with the media file, if applicable (e.g. for images).
66
     * This can be used for accessibility purposes.
67
     * @var string|null
68
     */
69
    public ?string $fileAlternativeText = null;
70

71
    /**
72
     * Filesystem visibility to set for the stored file (e.g. "public" or "private").
73
     * If null, the default visibility of the filesystem will be used.
74
     * @var string|null
75
     */
76
    public ?string $fileVisibility = null;
77

78
    /**
79
     * Additional options to pass to the filesystem when storing the file.
80
     * @var array
81
     */
82
    public array $filesystemOptions = [];
83

84
    /**
85
     * List of file sanitizer classes to apply to the uploaded file before saving.
86
     * @var list<class-string<SanitizerInterface>>
87
     */
88
    public array $fileSanitizers;
89
    public ?ImageManipulation $imageManipulation = null;
90

91
    /**
92
     * A callback that will be called before saving the media record to the database.
93
     * @var \Closure|null
94
     */
95
    public ?\Closure $beforeSaveCallback = null;
96

97
    /**
98
     * @var class-string<Media>
99
     */
100
    public string $modelClass;
101

102
    public OnDuplicateBehaviour $onDuplicate;
103

104
    public function __construct(array $config)
105
    {
106
        $this->definedAggregateTypes = $config['aggregate_types'] ?? [];
912✔
107
        $this->allowedAggregateTypes = $config['allowed_aggregate_types'] ?? [];
912✔
108
        $this->allowUnrecognizedTypes = $config['allow_unrecognized_types'] ?? false;
912✔
109
        $this->strictTypeChecking = $config['strict_type_checking'] ?? false;
912✔
110

111
        $this->maxUploadSize = $config['max_size'] ?? 0;
912✔
112
        $this->allowedExtensions = $config['allowed_extensions'] ?? [];
912✔
113
        $this->forbiddenExtensions = $config['forbidden_extensions'] ?? [];
912✔
114
        $this->allowedMimeTypes = $config['allowed_mime_types'] ?? [];
912✔
115
        $this->forbiddenMimeTypes = $config['forbidden_mime_types'] ?? [];
912✔
116
        $this->preferClientMimeType = $config['prefer_client_mime_type'] ?? false;
912✔
117

118
        $this->allowedDisks = $config['allowed_disks'] ?? [];
912✔
119
        $this->destinationDisk = $config['destination_disk'] ?? '';
912✔
120
        $this->defaultDisk = $config['default_disk'] ?? '';
912✔
121
        $this->destinationDirectory = $config['destination_directory'] ?? '';
912✔
122
        $this->destinationFilename = $config['destination_filename'] ?? null;
912✔
123
        $this->hashFilenameAlgorithm = $config['hash_filename_algorithm'] ?? null;
912✔
124

125
        $this->modelClass = $config['model'] ?? Media::class;
912✔
126
        $this->fileSanitizers = $config['file_sanitizers'] ?? [];
912✔
127
        $this->imageManipulation = null;
912✔
128
        $this->onDuplicate = OnDuplicateBehaviour::tryFrom($config['on_duplicate'] ?? 'increment')
912✔
NEW
129
            ?? OnDuplicateBehaviour::Increment;
×
130

131
    }
132

133
    public static function fromConfig(): self
134
    {
135
        return new self(config('mediable', []));
912✔
136
    }
137
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc