Completed
Branch master (e25020)
by Richan
03:06
created

RepositoryManager::getDatasource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
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()
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()
38
    {
39
        return new JsonRepository($this->getDatasource());
40
    }
41
42
    /**
43
     * Get language datasource.
44
     *
45
     * @return string
46
     */
47
    protected function getDatasource()
48
    {
49
        return $this->app['config']['i18n.language_datasource'];
50
    }
51
52
    /**
53
     * Get the default driver name.
54
     *
55
     * @return string
56
     */
57
    public function getDefaultDriver()
58
    {
59
        return $this->app['config']['i18n.driver'];
60
    }
61
}
62