Completed
Push — dependabot/npm_and_yarn/tippy.... ( 40037f...deaa3c )
by
unknown
400:02 queued 379:38
created

ManagesMedia::populateMedia()   A

Complexity

Conditions 5
Paths 9

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 5

Importance

Changes 3
Bugs 2 Features 0
Metric Value
eloc 11
c 3
b 2
f 0
dl 0
loc 21
ccs 12
cts 12
cp 1
rs 9.6111
cc 5
nc 9
nop 1
crap 5
1
<?php
2
3
namespace Thinktomorrow\Chief\Management;
4
5
use Illuminate\Http\Request;
6
use Thinktomorrow\Chief\Fields\Fields;
7
use Thinktomorrow\Chief\Media\UploadMedia;
8
9
trait ManagesMedia
10
{
11 76
    public function uploadMedia(Fields $fields, Request $request)
12
    {
13 76
        $files = array_merge_recursive($request->get('files', []), $request->file('files', []));
0 ignored issues
show
Bug introduced by
It seems like $request->file('files', array()) can also be of type Illuminate\Http\UploadedFile and null; however, parameter $_ of array_merge_recursive() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

13
        $files = array_merge_recursive($request->get('files', []), /** @scrutinizer ignore-type */ $request->file('files', []));
Loading history...
14 76
        $filesOrder = $request->get('filesOrder', []);
15
        
16 76
        app(UploadMedia::class)->fromUploadComponent($this->model, $files, $filesOrder);
17 76
    }
18
}
19