Passed
Pull Request — main (#161)
by Daniel
04:07
created

PublicUrlGenerator::generateUrl()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 4
dl 0
loc 6
ccs 0
cts 4
cp 0
crap 6
rs 10
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Components 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\ApiComponentsBundle\Factory\Uploadable;
15
16
use League\Flysystem\Config;
17
use League\Flysystem\Filesystem;
18
use League\Flysystem\UrlGeneration\PublicUrlGenerator as FlysystemPublicUrlGenerator;
19
use Silverback\ApiComponentsBundle\Exception\InvalidArgumentException;
20
21
class PublicUrlGenerator implements UploadableUrlGeneratorInterface
22
{
23
    public function generateUrl(object $object, string $fileProperty, Filesystem $filesystem, string $path): string
24
    {
25
        if (!$filesystem instanceof FlysystemPublicUrlGenerator) {
26
            throw new InvalidArgumentException(sprintf('The public URL generator requires a filesystem implementing %s', FlysystemPublicUrlGenerator::class));
27
        }
28
        return $filesystem->publicUrl($path, new Config([]));
0 ignored issues
show
Bug introduced by
new League\Flysystem\Config(array()) of type League\Flysystem\Config is incompatible with the type array expected by parameter $config of League\Flysystem\Filesystem::publicUrl(). ( Ignorable by Annotation )

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

28
        return $filesystem->publicUrl($path, /** @scrutinizer ignore-type */ new Config([]));
Loading history...
29
    }
30
}
31