Issues (238)

src/Loaders/Loader.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Translation\Loaders;
4
5
use Illuminate\Config\Repository as Config;
0 ignored issues
show
The type Illuminate\Config\Repository was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Contracts\Translation\Loader as LoaderContract;
7
use Translation\Repositories\LanguageRepository;
8
use Translation\Repositories\TranslationRepository;
9
10
abstract class Loader implements LoaderContract
11
{
12
    /**
13
     * The default locale.
14
     *
15
     * @var string
16
     */
17
    protected $defaultLocale;
18
19
    /**
20
     *  Create a new loader instance.
21
     *
22
     * @param \Translation\Repositories\LanguageRepository    $languageRepository
23
     * @param \Translation\Repositories\TranslationRepository $translationRepository
24
     * @param \Illuminate\Config\Repository                   $config
25
     */
26
    public function __construct($defaultLocale)
27
    {
28
        $this->defaultLocale = $defaultLocale;
29
    }
30
31
    /**
32
     * Load the messages for the given locale.
33
     *
34
     * @param  string $locale
35
     * @param  string $group
36
     * @param  string $namespace
37
     * @return array
38
     */
39
    public function load($locale, $group, $namespace = null)
40
    {
41
        if ($locale != $this->defaultLocale) {
42
            return array_replace_recursive(
43
                $this->loadSource($this->defaultLocale, $group, $namespace),
44
                $this->loadSource($locale, $group, $namespace)
45
            );
46
        }
47
        return $this->loadSource($locale, $group, $namespace);
48
    }
49
50
    /**
51
     * Load the messages for the given locale from the loader source (cache, file, database, etc...)
52
     *
53
     * @param  string $locale
54
     * @param  string $group
55
     * @param  string $namespace
56
     * @return array
57
     */
58
    abstract public function loadSource($locale, $group, $namespace = null);
59
60
    /**
61
     * Add a new namespace to the loader.
62
     *
63
     * @param  string $namespace
64
     * @param  string $hint
65
     * @return void
66
     */
67
    abstract public function addNamespace($namespace, $hint);
68
69
    /**
70
     * Add a new JSON path to the loader.
71
     *
72
     * @param  string $path
73
     * @return void
74
     **/
75
    abstract public function addJsonPath($path);
76
77
    /**
78
     * Get an array of all the registered namespaces.
79
     *
80
     * @return array
81
     */
82
    abstract public function namespaces();
83
}
84