Passed
Push — master ( 930acb...b95699 )
by Nasrul Hazim
20:22 queued 09:36
created

UserFactory::definition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
nc 1
nop 0
dl 0
loc 8
c 1
b 0
f 0
cc 1
rs 10
1
<?php
2
3
namespace Workbench\Database\Factories;
4
5
use Illuminate\Database\Eloquent\Factories\Factory;
6
use Illuminate\Support\Facades\Hash;
7
use Illuminate\Support\Str;
8
use Workbench\App\Models\User;
9
10
/**
11
 * @template TModel of \Workbench\App\Models\User
12
 *
13
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<TModel>
14
 */
15
class UserFactory extends Factory
16
{
17
    /**
18
     * The current password being used by the factory.
19
     */
20
    protected static ?string $password;
21
22
    /**
23
     * The name of the factory's corresponding model.
24
     *
25
     * @var class-string<TModel>
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<TModel> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<TModel>.
Loading history...
26
     */
27
    protected $model = User::class;
28
29
    /**
30
     * Define the model's default state.
31
     *
32
     * @return array<string, mixed>
33
     */
34
    public function definition(): array
35
    {
36
        return [
37
            'name' => fake()->name(),
38
            'email' => fake()->unique()->safeEmail(),
39
            'email_verified_at' => now(),
40
            'password' => static::$password ??= Hash::make('password'),
41
            'remember_token' => Str::random(10),
42
        ];
43
    }
44
45
    /**
46
     * Indicate that the model's email address should be unverified.
47
     */
48
    public function unverified(): static
49
    {
50
        return $this->state(fn (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(fn (/** @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
            'email_verified_at' => null,
52
        ]);
53
    }
54
}
55