Passed
Pull Request — master (#52)
by Daniel
05:37
created

File   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 11
c 1
b 0
f 0
dl 0
loc 22
ccs 4
cts 5
cp 0.8
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 3
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
    public string $fileFieldName = 'file';
28
29
    public string $filePathFieldName = 'filePath';
30
31
    public string $uploadedAtFieldName = 'uploadedAt';
32
33
    public string $mediaObjectsProperty = 'mediaObjects';
34
35
    public string $uploadsFieldName = 'uploadsResource';
36
37
    /** @required */
38
    public ?string $uploadsEntityClass;
39
40 9
    public function __construct(array $values)
41
    {
42 9
        if (!class_exists(Filesystem::class)) {
43
            throw new UnsupportedAnnotationException(sprintf('%s does not exist. Please install FlySystem v2 to use the @Silverback\Files annotation', Filesystem::class));
44
        }
45 9
        if (isset($values['value'])) {
46 9
            $this->uploadsEntityClass = $values['value'];
47
        }
48 9
    }
49
}
50