Locale   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 3 1
A setLocale() 0 4 1
A getCurrentTitle() 0 6 1
A current() 0 3 1
1
<?php
2
3
namespace Yaro\Jarboe\Helpers;
4
5
class Locale
6
{
7
    public function current()
8
    {
9
        return session('jarboe.locale', config('jarboe.locales.default'));
10
    }
11
12
    public function setLocale($locale)
13
    {
14
        session(['jarboe.locale' => $locale]);
15
        app()->setLocale($locale);
0 ignored issues
show
introduced by
The method setLocale() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

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

15
        app()->/** @scrutinizer ignore-call */ setLocale($locale);
Loading history...
16
    }
17
18
    public function all()
19
    {
20
        return config('jarboe.locales.list', []);
21
    }
22
23
    public function getCurrentTitle(): string
24
    {
25
        $list = $this->all();
26
        $title = $list[$this->current()] ?? '';
27
28
        return (string) $title;
29
    }
30
}
31