Code Duplication    Length = 22-22 lines in 2 locations

src/Builder.php 2 locations

@@ 40-61 (lines=22) @@
37
     *
38
     * @return array
39
     **/
40
    public static function addNames($codes)
41
    {
42
        // Get languages from config
43
        $languages = config('localizer.languages');
44
45
        $array = [];
46
47
        // Generate an array with $code as key and $code language as value
48
        foreach ($codes as $code) {
49
            $lang_name = 'Unknown';
50
51
            foreach ($languages as $language) {
52
                if ($language['code'] == $code) {
53
                    $lang_name = $language['name'];
54
                }
55
            }
56
57
            $array[$code] = $lang_name;
58
        }
59
60
        return $array;
61
    }
62
63
    /**
64
     * Add names to an array of language codes as [$language => $code].
@@ 70-91 (lines=22) @@
67
     *
68
     * @return array
69
     **/
70
    public static function addCodes($langs)
71
    {
72
        // Get languages from config
73
        $languages = config('localizer.languages');
74
75
        $array = [];
76
77
        // Generate an array with $lang as key and $lang code as value
78
        foreach ($langs as $lang) {
79
            $lang_code = 'unk';
80
81
            foreach ($languages as $language) {
82
                if ($language['name'] == $lang) {
83
                    $lang_code = $language['code'];
84
                }
85
            }
86
87
            $array[$lang] = $lang_code;
88
        }
89
90
        return $array;
91
    }
92
93
    /**
94
     * Returns the url to set up language and return back.