Passed
Push — master ( 0bc69d...cc8e66 )
by Stephen
56s queued 13s
created

TrackActionFactory::definition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 5
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
namespace Database\Factories;
4
5
use Database\Factories\Traits\ModelChanges;
6
use Illuminate\Database\Eloquent\Factories\Factory;
7
use Sfneal\Tracking\Models\TrackAction;
8
9
class TrackActionFactory extends Factory
10
{
11
    use ModelChanges;
12
13
    /**
14
     * The name of the factory's corresponding model.
15
     *
16
     * @var string
17
     */
18
    protected $model = TrackAction::class;
19
20
    /**
21
     * Define the model's default state.
22
     *
23
     * @return array
24
     */
25
    public function definition(): array
26
    {
27
        return [
28
            'action' => $this->faker->randomElement($this->randomAction()),
29
            'model_table' => 'people',
30
            'model_key' => $this->faker->randomNumber(3),
31
            'model_changes' => $this->faker->randomElements($this->modelChanges()),
32
        ];
33
    }
34
35
    /**
36
     * Retrieve an array of 'actions' to be used as random elements.
37
     *
38
     * @return array
39
     */
40
    protected function randomAction(): array
41
    {
42
        return collect(['created', 'updated', 'deleted'])->each(function (string $action) {
43
            return ucfirst($action).' the model.';
44
        })->toArray();
45
    }
46
}
47