Passed
Push — master ( 51edae...d29a9b )
by Curtis
11:52 queued 05:54
created

Storer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 1
A __construct() 0 4 1
1
<?php
2
3
namespace App\Service\enso\Localisation;
4
5
use Illuminate\Support\Facades\DB;
6
use App\Models\enso\Localisation\Language;
7
use App\Service\enso\Localisation\Json\Storer as JsonStorer;
8
use LaravelEnso\Localisation\Services\Legacy\Storer as LegacyStorer;
9
10
class Storer
11
{
12
    private array $request;
13
    private ?string $flagSuffix;
14
15
    public function __construct(array $request, $flagSuffix)
16
    {
17
        $this->request = $request;
18
        $this->flagSuffix = $flagSuffix;
19
    }
20
21
    public function create()
22
    {
23
        return DB::transaction(function () {
24
            $language = (new Language())
25
                ->storeWithFlagSufix($this->request, $this->flagSuffix);
0 ignored issues
show
Bug introduced by
It seems like $this->flagSuffix can also be of type null; however, parameter $sufix of App\Models\enso\Localisa...e::storeWithFlagSufix() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

25
                ->storeWithFlagSufix($this->request, /** @scrutinizer ignore-type */ $this->flagSuffix);
Loading history...
26
27
            (new LegacyStorer($this->request['name']))->create();
28
            (new JsonStorer($this->request['name']))->create();
29
30
            return $language;
31
        });
32
    }
33
}
34