TrackedNotificationFactory::definition()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
nc 1
nop 0
dl 0
loc 7
c 0
b 0
f 0
cc 1
rs 10
1
<?php
2
3
namespace NotificationTracker\Database\Factories;
4
5
use Illuminate\Database\Eloquent\Factories\Factory;
6
use Illuminate\Notifications\Notification;
7
use NotificationTracker\Models\TrackedNotification;
8
use NotificationTracker\Tests\Fixtures\Notifications\CertifiedNotification;
9
10
class TrackedNotificationFactory extends Factory
11
{
12
    /**
13
     * The name of the factory's corresponding model.
14
     *
15
     * @var string
16
     */
17
    protected $model = TrackedNotification::class;
18
19
    public function definition(): array
20
    {
21
        $resetPasswordNotification = new CertifiedNotification();
22
23
        return [
24
            'class' => $resetPasswordNotification::class,
25
            'data'  => serialize($resetPasswordNotification),
26
        ];
27
    }
28
29
    public function forNotification(Notification $notification = null): static
30
    {
31
        return $this->state([
32
            'class' => $notification::class,
33
            'data'  => serialize($notification),
34
        ]);
35
    }
36
}
37