MediaLibraryRequestItem   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromArray() 0 12 1
A __construct() 0 8 1
1
<?php
2
3
namespace Spatie\MediaLibraryPro\Dto;
4
5
use Illuminate\Support\Str;
6
7
class MediaLibraryRequestItem
8
{
9
    public static function fromArray(array $properties): self
10
    {
11
        $properties = collect($properties)
12
            ->keyBy(fn ($value, $key) => Str::snake($key));
13
14
        return new static(
15
            $properties['uuid'],
16
            $properties['name'] ?? '',
17
            $properties['order'] ?? 0,
18
            $properties['custom_properties'] ?? [],
19
            $properties['custom_headers'] ?? [],
20
            $properties['file_name'] ?? null,
21
        );
22
    }
23
24
    protected function __construct(
25
        public string $uuid,
26
        public string $name,
27
        public int $order,
28
        public array $customProperties,
29
        public array $customHeaders,
30
        public ?string $fileName = null,
31
    ) {
32
    }
33
}
34