Completed
Push — master ( b69e83...ad913f )
by Vladimir
02:54
created

FilesystemServiceProvider::adapter()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
nc 1
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Filesystem;
6
7
use League\Flysystem\Filesystem;
8
use League\Flysystem\AdapterInterface;
9
use League\Container\ServiceProvider\AbstractServiceProvider;
10
11
abstract class FilesystemServiceProvider extends AbstractServiceProvider
12
{
13
    protected $provides = [
14
        Filesystem::class,
15
    ];
16
17
    /**
18
     * Filesystem adapter.
19
     *
20
     * @return \League\Flysystem\AdapterInterface
21
     */
22
    abstract public function adapter(): AdapterInterface;
23
24
    /**
25
     * Use the register method to register items with the container via the
26
     * protected $this->container property or the `getContainer` method
27
     * from the ContainerAwareTrait.
28
     *
29
     * @return void
30
     */
31
    public function register(): void
32
    {
33 1
        $this->getContainer()->share(Filesystem::class, function () {
34 1
            return new Filesystem($this->adapter());
35 1
        });
36 1
    }
37
}
38