Passed
Push — master ( 62594f...a81262 )
by Mihail
08:04
created

LanguageSwitcher   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 5
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 6 1
A display() 0 22 2
1
<?php
2
3
namespace Widgets\Basic;
4
5
6
use Ffcms\Core\App;
7
use Ffcms\Core\Arch\Widget;
8
use Ffcms\Core\Helper\HTML\Listing;
9
10
class LanguageSwitcher extends Widget
11
{
12
    public function init()
13
    {
14
        parent::init();
15
16
17
    }
18
19
    public function display()
20
    {
21
        parent::display();
22
23
        App::$Alias->setCustomLibrary('css', '/vendor/phpffcms/language-flags/flags.css');
24
25
        $items = [];
26
        foreach (App::$Translate->getAvailableLangs() as $lang) {
27
            $items[] = [
28
                'type' => 'text',
29
                'text' => '<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="flag flag-'.$lang.'" />',
30
                'html' => true,
31
                '!secure' => true
32
            ];
33
        }
34
35
        return Listing::display([
36
            'type' => 'ul',
37
            'property' => ['class' => 'list-inline'],
38
            'items' => $items
39
        ]);
40
    }
41
}