Issues (238)

src/Loaders/FileLoader.php (1 issue)

1
<?php
2
3
namespace Translation\Loaders;
4
5
use Illuminate\Translation\FileLoader as LaravelFileLoader;
6
7
class FileLoader extends Loader
8
{
9
    /**
10
     * The default locale.
11
     *
12
     * @var string
13
     */
14
    protected $defaultLocale;
15
16
    /**
17
     * The laravel file loader instance.
18
     *
19
     * @var \Illuminate\Translation\FileLoader
20
     */
21
    protected $laravelFileLoader;
22
23
    /**
24
     *  Create a new mixed loader instance.
25
     *
26
     * @param  string                             $defaultLocale
27
     * @param  \Illuminate\Translation\FileLoader $laravelFileLoader
28
     * @return void
29
     */
30
    public function __construct($defaultLocale, LaravelFileLoader $laravelFileLoader)
31
    {
32
        parent::__construct($defaultLocale);
33
        $this->laravelFileLoader = $laravelFileLoader;
34
    }
35
36
    /**
37
     * Load the messages strictly for the given locale without checking the cache or in case of a cache miss.
38
     *
39
     * @param  string $locale
40
     * @param  string $group
41
     * @param  string $namespace
42
     * @return array
43
     */
44
    public function loadSource($locale, $group, $namespace = '*')
45
    {
46
        return $this->laravelFileLoader->load($locale, $group, $namespace);
47
    }
48
49
    /**
50
     * Add a new namespace to the loader.
51
     *
52
     * @param  string $namespace
53
     * @param  string $hint
54
     * @return void
55
     */
56
    public function addNamespace($namespace, $hint)
57
    {
58
        $this->hints[$namespace] = $hint;
0 ignored issues
show
Bug Best Practice introduced by
The property hints does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
59
        $this->laravelFileLoader->addNamespace($namespace, $hint);
60
    }
61
62
    /**
63
     * Add a new JSON path to the loader.
64
     *
65
     * @param  string $path
66
     * @return void
67
     */
68
    public function addJsonPath($path)
69
    {
70
        $this->laravelFileLoader->addJsonPath($path);
71
    }
72
73
    /**
74
     * Get an array of all the registered namespaces.
75
     *
76
     * @return array
77
     */
78
    public function namespaces()
79
    {
80
        return $this->hints;
81
    }
82
}
83