FileAdderFactory::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace ByTIC\MediaLibrary\FileAdder;
4
5
use ByTIC\MediaLibrary\HasMedia\HasMediaTrait;
6
7
/**
8
 * Class FileAdderFactory.
9
 */
10
class FileAdderFactory
11
{
12
    /**
13
     * @param HasMediaTrait                                      $subject
14
     * @param string|\Symfony\Component\HttpFoundation\File\File $file
15
     *
16
     * @throws \Nip\Logger\Exception
17
     *
18
     * @return FileAdder
19
     * @throws \Nip\Logger\Exception
20
     */
21 2
    public static function create($subject, $file)
22
    {
23 2
        return static::newFileAdder()
24 2
            ->setSubject($subject)
25 2
            ->setFile($file);
26
    }
27
28
    /**
29
     * @return FileAdder
30
     */
31 2
    public static function newFileAdder()
32
    {
33 2
        if (function_exists('app')) {
34 2
            app(FileAdder::class);
35
        }
36
37 2
        return new FileAdder();
38
    }
39
}
40