ObjectStorageServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 2
b 0
f 0
dl 0
loc 12
ccs 3
cts 4
cp 0.75
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 10 3
1
<?php
2
3
namespace App\Providers;
4
5
use Aws\AwsClientInterface;
6
use Aws\S3\S3ClientInterface;
7
use Illuminate\Support\ServiceProvider;
8
9
class ObjectStorageServiceProvider extends ServiceProvider
10
{
11 132
    public function register(): void
12
    {
13
        $this->app->bind(S3ClientInterface::class, static function (): ?AwsClientInterface {
14
            // If these two values are not configured in .env, AWS will attempt initializing
15
            // the client with null values and throw an error.
16 13
            if (!config('aws.credentials.key') || !config('aws.credentials.secret')) {
17 13
                return null;
18
            }
19
20
            return app('aws')->createClient('s3');
21 132
        });
22 132
    }
23
}
24