Passed
Push — develop ( 9324e6...f3eb57 )
by Septianata
04:31
created

OrderStatusFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A draft() 0 4 1
A definition() 0 5 1
1
<?php
2
3
namespace Database\Factories;
4
5
use App\Enum\OrderStatus as EnumOrderStatus;
6
use App\Models\OrderStatus as ModelOrderStatus;
7
use Illuminate\Database\Eloquent\Factories\Factory;
8
9
class OrderStatusFactory extends Factory
10
{
11
    /**
12
     * The name of the factory's corresponding model.
13
     *
14
     * @var string
15
     */
16
    protected $model = ModelOrderStatus::class;
17
18
    /**
19
     * Define the model's default state.
20
     *
21
     * @return array
22
     */
23
    public function definition()
24
    {
25
        return [
26
            'status' => EnumOrderStatus::from($this->faker->randomElement(EnumOrderStatus::toValues())),
0 ignored issues
show
Bug introduced by
The call to Faker\Generator::randomElement() has too few arguments starting with 'b'. ( Ignorable by Annotation )

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

26
            'status' => EnumOrderStatus::from($this->faker->/** @scrutinizer ignore-call */ randomElement(EnumOrderStatus::toValues())),

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
27
            'note' => $this->faker->randomElement([null, $this->faker->text]),
28
        ];
29
    }
30
31
    /**
32
     * Indicate that the status is "draft".
33
     *
34
     * @return \Illuminate\Database\Eloquent\Factories\Factory
35
     */
36
    public function draft()
37
    {
38
        return $this->state([
39
            'status' => EnumOrderStatus::draft(),
40
        ]);
41
    }
42
}
43