Passed
Push — develop ( b27e40...fcd18c )
by Septianata
43:54
created

UserFactory::activate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Database\Factories;
4
5
use App\Enum\Gender;
6
use App\Models\User;
7
use Illuminate\Database\Eloquent\Factories\Factory;
8
use Illuminate\Support\Carbon;
9
use Illuminate\Support\Str;
10
11
class UserFactory extends Factory
12
{
13
    /**
14
     * The name of the factory's corresponding model.
15
     *
16
     * @var string
17
     */
18
    protected $model = User::class;
19
20
    /**
21
     * Define the model's default state.
22
     *
23
     * @return array
24
     */
25
    public function definition()
26
    {
27
        $gender = $this->faker->randomElement(Gender::toValues());
28
29
        return [
30
            'username' => $this->faker->userName,
31
            'fullname' => $this->faker->name($gender),
32
            'gender' => $gender,
33
            'email' => $this->faker->unique()->safeEmail(),
34
            'phone_country' => env('PHONE_COUNTRY', 'ID'),
35
            'phone' => $this->faker->numerify('081#########'),
36
            'email_verified_at' => Carbon::now(),
37
            'password' => 'password',
38
            'remember_token' => Str::random(10),
39
            'is_active' => true,
40
        ];
41
    }
42
43
    /**
44
     * Indicate that the model's email address should be unverified.
45
     *
46
     * @return \Illuminate\Database\Eloquent\Factories\Factory
47
     */
48
    public function unverified()
49
    {
50
        return $this->state(function (array $attributes) {
0 ignored issues
show
Unused Code introduced by
The parameter $attributes is not used and could be removed. ( Ignorable by Annotation )

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

50
        return $this->state(function (/** @scrutinizer ignore-unused */ array $attributes) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
51
            return [
52
                'email_verified_at' => null,
53
            ];
54
        });
55
    }
56
57
    /**
58
     * Indicate that the model's account should be unactivate.
59
     *
60
     * @return \Illuminate\Database\Eloquent\Factories\Factory
61
     */
62
    public function unactivate()
63
    {
64
        return $this->state(function (array $attributes) {
0 ignored issues
show
Unused Code introduced by
The parameter $attributes is not used and could be removed. ( Ignorable by Annotation )

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

64
        return $this->state(function (/** @scrutinizer ignore-unused */ array $attributes) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
65
            return [
66
                'is_active' => false,
67
            ];
68
        });
69
    }
70
71
    /**
72
     * Indicate that the model's account should be activate.
73
     *
74
     * @return \Illuminate\Database\Eloquent\Factories\Factory
75
     */
76
    public function activate()
77
    {
78
        return $this->state(function (array $attributes) {
0 ignored issues
show
Unused Code introduced by
The parameter $attributes is not used and could be removed. ( Ignorable by Annotation )

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

78
        return $this->state(function (/** @scrutinizer ignore-unused */ array $attributes) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
79
            return [
80
                'is_active' => true,
81
            ];
82
        });
83
    }
84
}
85