Passed
Push — master ( 988f4e...b3bcb6 )
by Alexander
06:25
created

DefaultHandler::getAllTranslations()   A

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 1
1
<?php
2
3
/**
4
 *
5
 * Base Handler to extend from
0 ignored issues
show
Coding Style introduced by
Doc comment short description must be on the first line
Loading history...
6
 *
7
 * @package  Hokan22\LaravelTranslator\Handler
0 ignored issues
show
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 2
Loading history...
8
 * @author   Alexander Viertel <[email protected]>
0 ignored issues
show
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 3
Loading history...
9
 * @license  http://opensource.org/licenses/MIT MIT
0 ignored issues
show
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 2
Loading history...
10
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @link tag in file comment
Loading history...
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
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
19
class TranslationNotFoundException extends \Exception {}
0 ignored issues
show
Coding Style introduced by
Opening brace of a class must be on the line after the definition
Loading history...
Coding Style introduced by
Closing brace must be on a line by itself
Loading history...
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
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
26
class TranslationNotInCacheException extends TranslationNotFoundException {}
0 ignored issues
show
Coding Style introduced by
Opening brace of a class must be on the line after the definition
Loading history...
Coding Style introduced by
Closing brace must be on a line by itself
Loading history...
27
28
/**
29
 * Custom Exception thrown when a cache file could not be found
30
 *
31
 * Class TranslationCacheNotFound
32
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
33
class TranslationCacheNotFound extends \Exception {}
0 ignored issues
show
Coding Style introduced by
Opening brace of a class must be on the line after the definition
Loading history...
Coding Style introduced by
Closing brace must be on a line by itself
Loading history...
34
35
/**
36
 * Interface HandlerInterface
37
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
38
class DefaultHandler
39
{
40
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
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
    /**
0 ignored issues
show
Coding Style introduced by
Doc comment for parameter "$locale" missing
Loading history...
47
     * HandlerInterface constructor.
48
     *
49
     * @param $locale
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter name
Loading history...
50
     */
51
    function __construct($locale){
0 ignored issues
show
Coding Style introduced by
Opening brace should be on a new line
Loading history...
52
         $this->locale = $locale;
53
    }
54
55
    /**
56
     * Should return the locale currently set in the handler
57
     *
58
     * @return string
59
     */
60
    function getLocale(){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Coding Style introduced by
Opening brace should be on a new line
Loading history...
61
        return $this->locale;
62
    }
63
64
    /**
65
     * Get the translation of a given identifier
66
     *
67
     * @param string $identifier
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
68
     * @param string $group
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
69
     * @return string
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
70
     */
71
    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
    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...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Coding Style introduced by
Opening brace should be on a new line
Loading history...
72
        return $identifier;
73
    }
74
75
    /**
76
     * Refresh the internal Cache
77
     *
78
     * @return bool
79
     */
80
    function refreshCache(){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Coding Style introduced by
Opening brace should be on a new line
Loading history...
81
        return true;
82
    }
83
84
    /**
85
     * Get all translations of a given group
86
     *
87
     * @param string $group
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
88
     * @return array
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
89
     */
90
    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
    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...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Coding Style introduced by
Opening brace should be on a new line
Loading history...
91
        return [];
92
    }
93
94
}