Code Duplication    Length = 18-18 lines in 2 locations

src/MultiLang/MultiLang.php 1 location

@@ 383-400 (lines=18) @@
380
        $table   = $this->getTableName();
381
        $locales = $this->getLocales();
382
383
        foreach ($this->new_texts as $k => $v) {
384
            foreach ($locales as $lang => $locale_data) {
385
                $exists = $this->getDb()->table($table)->where([
386
                    'key'  => $k,
387
                    'lang' => $lang,
388
                ])->first();
389
390
                if ($exists) {
391
                    continue;
392
                }
393
394
                $this->getDb()->table($table)->insert([
395
                    'key'   => $k,
396
                    'lang'  => $lang,
397
                    'value' => $v,
398
                ]);
399
            }
400
        }
401
        return true;
402
    }
403

src/MultiLang/Repository.php 1 location

@@ 130-147 (lines=18) @@
127
        $table   = $this->getTableName();
128
        $locales = $this->getLocales();
129
130
        foreach ($texts as $k => $v) {
131
            foreach ($locales as $lang => $locale_data) {
132
                $exists = $this->getDb()->table($table)->where([
133
                    'key'  => $k,
134
                    'lang' => $lang,
135
                ])->first();
136
137
                if ($exists) {
138
                    continue;
139
                }
140
141
                $this->getDb()->table($table)->insert([
142
                    'key'   => $k,
143
                    'lang'  => $lang,
144
                    'value' => $v,
145
                ]);
146
            }
147
        }
148
        return true;
149
    }
150