RepositoryManager   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 52
c 0
b 0
f 0
wmc 5
lcom 0
cbo 3
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createDatabaseDriver() 0 4 1
A createJsonDriver() 0 4 1
A getDatasource() 0 4 1
A getDefaultDriver() 0 4 1
1
<?php
2
3
namespace RichanFongdasen\I18n;
4
5
use Illuminate\Foundation\Application;
6
use Illuminate\Support\Manager;
7
use RichanFongdasen\I18n\Repositories\DatabaseRepository;
8
use RichanFongdasen\I18n\Repositories\JsonRepository;
9
10
class RepositoryManager extends Manager
11
{
12
    /**
13
     * Class constructor.
14
     *
15
     * @param \Illuminate\Foundation\Application $app
16
     */
17
    public function __construct(Application $app)
18
    {
19
        parent::__construct($app);
20
    }
21
22
    /**
23
     * Create database repository.
24
     *
25
     * @return \RichanFongdasen\I18n\Repositories\DatabaseRepository
26
     */
27
    public function createDatabaseDriver(): DatabaseRepository
28
    {
29
        return new DatabaseRepository($this->getDatasource());
30
    }
31
32
    /**
33
     * Create json repository.
34
     *
35
     * @return \RichanFongdasen\I18n\Repositories\JsonRepository
36
     */
37
    public function createJsonDriver(): JsonRepository
38
    {
39
        return new JsonRepository($this->getDatasource());
40
    }
41
42
    /**
43
     * Get language datasource.
44
     *
45
     * @return string
46
     */
47
    protected function getDatasource(): string
48
    {
49
        return (string) config('i18n.language_datasource');
50
    }
51
52
    /**
53
     * Get the default driver name.
54
     *
55
     * @return string
56
     */
57
    public function getDefaultDriver(): string
58
    {
59
        return (string) config('i18n.driver', 'json');
60
    }
61
}
62