Completed
Push — master ( 1680b9...7d3d6e )
by Mohamed
15s queued 11s
created

Localization   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getLocale() 0 4 1
A getDirection() 0 4 1
A isRTL() 0 4 1
1
<?php
2
3
namespace Microboard\Foundations;
4
5
use Illuminate\Support\Collection;
6
7
class Localization
8
{
9
    /**
10
     * @var Collection
11
     */
12
    private $lang;
13
14
    /**
15
     * Localization constructor.
16
     */
17
    public function __construct()
18
    {
19
        $this->lang = collect(config('microboard.localizations', []));
20
    }
21
22
    /**
23
     * @return array
24
     */
25
    public function getLocale()
26
    {
27
        return $this->lang->where('code', app()->getLocale())->first();
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function getDirection()
34
    {
35
        return $this->getLocale()['dir'] ?? 'ltr';
36
    }
37
38
    /**
39
     * @return bool
40
     */
41
    public function isRTL()
42
    {
43
        return $this->getDirection() === 'rtl';
44
    }
45
}
46