Passed
Push — develop ( 6302a9...3db2fb )
by Septianata
04:45
created

DenominationFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 14
dl 0
loc 30
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A definition() 0 16 3
1
<?php
2
3
namespace Database\Factories;
4
5
use App\Enum\DenominationType;
6
use App\Models\Denomination;
7
use Illuminate\Database\Eloquent\Factories\Factory;
8
use Illuminate\Http\UploadedFile;
9
10
class DenominationFactory extends Factory
11
{
12
    /**
13
     * The name of the factory's corresponding model.
14
     *
15
     * @var string
16
     */
17
    protected $model = Denomination::class;
18
19
    /**
20
     * Define the model's default state.
21
     *
22
     * @return array
23
     */
24
    public function definition()
25
    {
26
        $isCoin = $this->faker->boolean;
27
28
        $denomination = $isCoin
29
            ? $this->faker->randomElement([100, 200, 500, 1000])
30
            : $this->faker->randomElement([1000, 2000, 5000, 10000, 20000, 50000, 75000, 100000]);
31
32
        return [
33
            'name' => terbilang($denomination),
34
            'value' => $denomination,
35
            'type' => $isCoin ? DenominationType::coin() : DenominationType::banknote(),
36
            'quantity_per_bundle' => $this->faker->randomElement([50, 100, 200]),
37
            'minimum_order_bundle' => $minimum = $this->faker->numberBetween(1, 10),
38
            'maximum_order_bundle' => $this->faker->numberBetween($minimum, 10),
39
            'image' => UploadedFile::fake()->image($denomination . '.jpg'),
40
        ];
41
    }
42
}
43