Test Failed
Pull Request — master (#38)
by Maximo
04:24
created

FileSystemProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 44.44%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 21
ccs 4
cts 9
cp 0.4444
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 16 2
1
<?php
2
3
namespace Gewaer\Providers;
4
5
use Phalcon\Di\ServiceProviderInterface;
6
use Phalcon\DiInterface;
7
use League\Flysystem\Adapter\Local;
8
use League\Flysystem\AwsS3v3\AwsS3Adapter;
9
use League\Flysystem\Filesystem;
10
11
class FileSystemProvider implements ServiceProviderInterface
12
{
13
    /**
14
     * @param DiInterface $container
15
     */
16 54
    public function register(DiInterface $container)
17
    {
18 54
        $config = $container->getShared('config');
19
20 54
        $container->setShared(
21 54
            'filesystem',
22
            function ($filesystem = 'local') use ($config) {
23
                if ($filesystem === 'local') {
24
                    //create directory
25
                    $adapter = new Local($config->filesystem->local->path);
26
                } else {
27
                    //s3
28
                    $client = S3Client::factory($config->filesystem->s3->info->toArray());
0 ignored issues
show
Bug introduced by
The type Gewaer\Providers\S3Client was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
29
                    $adapter = new AwsS3Adapter($client, $config->filesystem->s3->bucket, null, ['ACL' => 'public-read']);
30
                }
31
                return new Filesystem($adapter);
32 54
            }
33
        );
34 54
    }
35
}
36