Completed
Push — master ( f2c439...2a9983 )
by Neomerx
04:50
created

L10nSettings::getLocalesPath()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
1
<?php namespace Limoncello\Application\Packages\L10n;
2
3
/**
4
 * Copyright 2015-2017 [email protected]
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
use Limoncello\Contracts\Settings\SettingsInterface;
20
use Limoncello\l10n\Messages\FileBundleEncoder;
21
22
/**
23
 * @package Limoncello\Application
24
 */
25
abstract class L10nSettings implements SettingsInterface
26
{
27
    /** Settings key */
28
    const KEY_DEFAULT_LOCALE = 0;
29
30
    /** Settings key */
31
    const KEY_LOCALES_DATA = self::KEY_DEFAULT_LOCALE + 1;
32
33
    /** Settings key */
34
    const KEY_LAST = self::KEY_LOCALES_DATA;
35
36
    /**
37
     * @return string
38
     */
39
    abstract protected function getDefaultLocale(): string;
40
41
    /**
42
     * @return string
43
     */
44
    abstract protected function getLocalesPath(): string;
45
46
    /**
47
     * @inheritdoc
48
     */
49
    public function get(): array
50
    {
51
        $defaultLocale = $this->getDefaultLocale();
52
        $loader        = (new FileBundleEncoder($this->getLocalesPath()));
53
54
        return [
55
            static::KEY_DEFAULT_LOCALE => $defaultLocale,
56
            static::KEY_LOCALES_DATA   => $loader->getStorageData($defaultLocale),
57
        ];
58
    }
59
}
60