Completed
Pull Request — master (#169)
by Mikołaj
05:25
created

MediaProviderResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 18
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A resolveProvider() 0 7 1
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project.
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusCmsPlugin\Resolver;
14
15
use BitBag\SyliusCmsPlugin\Entity\MediaInterface;
16
use BitBag\SyliusCmsPlugin\MediaProvider\ProviderInterface;
17
use Sylius\Component\Registry\ServiceRegistryInterface;
18
19
final class MediaProviderResolver implements MediaProviderResolverInterface
20
{
21
    /** @var ServiceRegistryInterface */
22
    private $providerRegistry;
23
24
    public function __construct(ServiceRegistryInterface $providerRegistry)
25
    {
26
        $this->providerRegistry = $providerRegistry;
27
    }
28
29
    public function resolveProvider(MediaInterface $media): ProviderInterface
30
    {
31
        /** @var ProviderInterface $provider */
32
        $provider = $this->providerRegistry->get($media->getType());
33
34
        return $provider;
35
    }
36
}
37