ThemesProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 27
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A findOneByName() 0 3 1
A getAll() 0 3 1
A getDefaultTheme() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Locastic\SymfonyTranslationBundle\Provider;
6
7
use Locastic\SymfonyTranslationBundle\Factory\ThemeFactoryInterface;
8
use Locastic\SymfonyTranslationBundle\Model\ThemeInterface;
9
10
final class ThemesProvider implements ThemesProviderInterface
11
{
12
    private DefaultTranslationDirectoryProviderInterface $defaultTranslationDirectoryProvider;
13
14
    private ThemeFactoryInterface $themeFactory;
15
16
    public function __construct(
17
        DefaultTranslationDirectoryProviderInterface $defaultTranslationDirectoryProvider,
18
        ThemeFactoryInterface $themeFactory
19
    ) {
20
        $this->defaultTranslationDirectoryProvider = $defaultTranslationDirectoryProvider;
21
        $this->themeFactory = $themeFactory;
22
    }
23
24
    public function getAll(): array
25
    {
26
        return [self::NAME_DEFAULT => $this->getDefaultTheme()];
27
    }
28
29
    public function findOneByName(string $name): ?ThemeInterface
30
    {
31
        return $this->getDefaultTheme();
32
    }
33
34
    public function getDefaultTheme(): ThemeInterface
35
    {
36
        return $this->themeFactory->createNew(self::NAME_DEFAULT, $this->defaultTranslationDirectoryProvider->getDefaultDirectory());
37
    }
38
}
39