BookingFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A definition() 0 10 2
1
<?php
2
3
namespace IproSync\Database\Factories;
4
5
use Carbon\Carbon;
6
use Illuminate\Database\Eloquent\Factories\Factory;
7
use IproSync\Models\Booking;
8
9
class BookingFactory extends Factory
10
{
11
    protected $model = Booking::class;
12
13
    public function definition(): array
14
    {
15
        do {
16
            $id = time() . rand(1, 9999);
17
        } while ($this->model::query()->whereKey($id)->exists());
18
19
        return [
20
            'id'        => $id . rand(1, 9999),
21
            'check_in'  => Carbon::now()->addDays(2),
22
            'check_out' => Carbon::now()->addDays(7),
23
        ];
24
    }
25
}
26