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

PublicUrlGenerator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
ccs 0
cts 4
cp 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateUrl() 0 6 2
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