Issues (52)

src/Seeds/CurrenciesTableSeeder.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Turahe\Master\Seeds;
4
5
use Illuminate\Database\Seeder;
6
use Turahe\Master\Models\Currency;
7
8
class CurrenciesTableSeeder extends Seeder
9
{
10
    /**
11
     * Run the database seeds.
12
     *
13
     * @return void
14
     */
15
    public function run()
16
    {
17
        //Get all of the currencies
18
        $file = __DIR__.'/../../resources/currencies.json';
19
20
        $data = json_decode(file_get_contents($file), true);
21
        $currencies = array_map(function ($currency) {
22
            return [
23
                'priority' => isset($currency['priority']) ? $currency['priority'] : 100,
24
                'iso_code' => isset($currency['iso_code']) ? $currency['iso_code'] : null,
25
                'name' => isset($currency['name']) ? $currency['name'] : null,
26
                'symbol' => isset($currency['symbol']) ? $currency['symbol'] : null,
27
                'disambiguate_symbol' => isset($currency['disambiguate_symbol']) ? $currency['disambiguate_symbol'] : null,
28
                'alternate_symbols' => isset($currency['alternate_symbols']) ? json_encode($currency['alternate_symbols'], true) : null,
0 ignored issues
show
true of type true is incompatible with the type integer expected by parameter $options of json_encode(). ( Ignorable by Annotation )

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

28
                'alternate_symbols' => isset($currency['alternate_symbols']) ? json_encode($currency['alternate_symbols'], /** @scrutinizer ignore-type */ true) : null,
Loading history...
29
                'subunit' => isset($currency['subunit']) ? $currency['subunit'] : null,
30
                'subunit_to_unit' => isset($currency['subunit_to_unit']) ? $currency['subunit_to_unit'] : 100,
31
                'symbol_first' => isset($currency['symbol_first']) ? $currency['symbol_first'] : 1,
32
                'html_entity' => isset($currency['html_entity']) ? $currency['html_entity'] : null,
33
                'decimal_mark' => isset($currency['decimal_mark']) ? $currency['decimal_mark'] : '.',
34
                'thousands_separator' => isset($currency['thousands_separator']) ? $currency['thousands_separator'] : ',',
35
                'iso_numeric' => isset($currency['iso_numeric']) ? $currency['iso_numeric'] : null,
36
                'smallest_denomination' => isset($currency['smallest_denomination']) ? $currency['smallest_denomination'] : 1,
37
                'created_at' => now()->toDateTimeString(),
38
                'updated_at' => now()->toDateTimeString(),
39
40
            ];
41
        }, $data);
42
43
        Currency::insert($currencies);
44
    }
45
}
46