Issues (238)

src/Services/Traits/LangServiceTrait.php (3 issues)

Labels
Severity
1
<?php
2
3
namespace Translation\Services\Traits;
4
5
use Illuminate\Support\Facades\Auth;
6
use Illuminate\Support\Facades\Config;
7
use Illuminate\Support\Facades\Gate;
8
use Illuminate\Support\Facades\URL;
9
use App\Repositories\LangRepository;
0 ignored issues
show
The type App\Repositories\LangRepository 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...
10
11
trait LangServiceTrait
12
{
13
14
    /**
15
     * Return menu for translation
16
     *
17
     * @return string
18
     */
19
    public function menu_lang()
20
    {
21
        $langs = LangRepository::get();
22
23
        if (!$langs || empty($langs)) {
24
            return '';
25
        }
26
27
        $current = LangRepository::getCurrent();
28
29
        $response = '<li>';
30
        $response .= '<a href=""><span class="'.$current['class'].'"></span></a>';
31
        $response .= '<ul class="sub-menu clearfix">';
32
        $response .= '<li class=\'no-translation menu-item current-lang \'><a href="'.url('language/set/'.$current['locale']).'"><span class="'.$current['class'].'"></span></a></li>';
0 ignored issues
show
The function url was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

32
        $response .= '<li class=\'no-translation menu-item current-lang \'><a href="'./** @scrutinizer ignore-call */ url('language/set/'.$current['locale']).'"><span class="'.$current['class'].'"></span></a></li>';
Loading history...
33
34
        foreach ($langs as $lang) {
35
            if ($lang['locale'] !== $current['locale']) {
36
                $response .= '<li class=\'no-translation menu-item\'><a href="'.url('language/set/'.$lang['locale']).'"><span class="'.$lang['class'].'"></span></a></li>';
37
            }
38
        }
39
40
        $response .= '</ul></li>';
41
42
        return $response;
43
    }
44
45
    /**
46
     * Get a especific image for current Lang.
47
     *
48
     * @param string $img_path
49
     *
50
     * @return string
51
     */
52
    public function img_lang($img_path)
53
    {
54
        $public_path = public_path();
0 ignored issues
show
The function public_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

54
        $public_path = /** @scrutinizer ignore-call */ public_path();
Loading history...
55
56
        $current = LangRepository::getCurrent();
57
        $min_lang = explode('-', $current['locale']);
58
59
        $break_path = explode('.', $img_path);
60
61
        $extensao = array_pop($break_path);
62
63
        if (file_exists($public_path.'/'.implode('.', $break_path).'-'.$current['locale'].'.'.$extensao)) {
64
            return implode('.', $break_path).'-'.$current['locale'].'.'.$extensao;
65
        }
66
67
        if (file_exists($public_path.'/'.implode('.', $break_path).'-'.$min_lang[0].'.'.$extensao)) {
68
            return implode('.', $break_path).'-'.$min_lang[0].'.'.$extensao;
69
        }
70
71
        return $img_path;
72
    }
73
}