Passed
Pull Request — master (#52)
by Vincent
11:12 queued 04:00
created

File::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.072

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 7
ccs 4
cts 5
cp 0.8
rs 10
cc 3
nc 3
nop 1
crap 3.072
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Component Bundle Project
5
 *
6
 * (c) Daniel West <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Silverback\ApiComponentBundle\Annotation;
15
16
use League\Flysystem\Filesystem;
17
use Silverback\ApiComponentBundle\Exception\UnsupportedAnnotationException;
18
19
/**
20
 * @author Daniel West <[email protected]>
21
 *
22
 * @Annotation
23
 * @Target("CLASS")
24
 */
25
final class File
26
{
27
    /** @required */
28
    public ?string $adapter;
29
30
    public string $path = 'uploads';
31
32
    public string $fileFieldName = 'file';
33
34
    public string $filePathFieldName = 'filePath';
35
36
    public string $mediaObjectsProperty = 'mediaObjects';
37
38
    public string $uploadsFieldName = 'uploadsResource';
39
40
    /** @required */
41
    public ?string $uploadsEntityClass;
42
43 9
    public function __construct(array $values)
44
    {
45 9
        if (!class_exists(Filesystem::class)) {
46
            throw new UnsupportedAnnotationException(sprintf('%s does not exist. Please install FlySystem v2 to use the @Silverback\File annotation', Filesystem::class));
47
        }
48 9
        if (isset($values['value'])) {
49 9
            $this->uploadsEntityClass = $values['value'];
50
        }
51 9
    }
52
}
53