DefaultHandler::refreshCache()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 *
5
 * Base Handler to extend from
6
 *
7
 * @package  Hokan22\LaravelTranslator\Handler
8
 * @author   Alexander Viertel <[email protected]>
9
 * @license  http://opensource.org/licenses/MIT MIT
10
 */
11
namespace Hokan22\LaravelTranslator\Handler;
12
13
/**
14
 * Custom Exception to distinguish if the Translation Identifier or
15
 * the Translation was not found for the given locale
16
 *
17
 * Class TranslationNotFoundException
18
 */
19
class TranslationNotFoundException extends \Exception {}
20
21
/**
22
 * Custom Exception to distinguish if the Translation Identifier was not found in Cache but could be in DB
23
 *
24
 * Class TranslationNotInCacheException
25
 */
26
class TranslationNotInCacheException extends TranslationNotFoundException {}
27
28
/**
29
 * Custom Exception thrown when a cache file could not be found
30
 *
31
 * Class TranslationCacheNotFound
32
 */
33
class TranslationCacheNotFound extends \Exception {}
34
35
/**
36
 * Interface HandlerInterface
37
 */
38
class DefaultHandler
39
{
40
    /**
41
     * @var string          $locale         The locale to translate to
42
     * @var array|array[]   $translations   Array with the identifiers as keys and the Texts object as value
43
     */
44
    protected $locale, $translations;
45
46
    /**
47
     * HandlerInterface constructor.
48
     *
49
     * @param $locale
50
     */
51
    public function __construct($locale) {
52
        $this->locale = $locale;
53
    }
54
55
    /**
56
     * Should return the locale currently set in the handler
57
     *
58
     * @return string
59
     */
60
    public function getLocale() {
61
        return $this->locale;
62
    }
63
64
    /**
65
     * Get the translation of a given identifier
66
     *
67
     * @param string $identifier
68
     * @param string $group
69
     * @return string
70
     */
71
    public function getTranslation($identifier, $group) {
0 ignored issues
show
Unused Code introduced by
The parameter $group is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

71
    public function getTranslation($identifier, /** @scrutinizer ignore-unused */ $group) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
72
        return $identifier;
73
    }
74
75
    /**
76
     * Refresh the internal Cache
77
     *
78
     * @return bool
79
     */
80
    public function refreshCache() {
81
        return true;
82
    }
83
84
    /**
85
     * Get all translations of a given group
86
     *
87
     * @param string $group
88
     * @return array
89
     */
90
    public function getAllTranslations($group) {
0 ignored issues
show
Unused Code introduced by
The parameter $group is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

90
    public function getAllTranslations(/** @scrutinizer ignore-unused */ $group) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
91
        return [];
92
    }
93
94
    /**
95
     * Get the DB ID of the Identifier
96
     *
97
     * @param $identifier
98
     * @return integer
99
     */
100
    public function getDatabaseID($identifier) {
101
        return 1;
102
    }
103
104
}