PostFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 19
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getClass() 0 3 1
A published() 0 4 1
A getDefaults() 0 5 1
1
<?php
2
3
namespace Zenstruck\Foundry\Tests\Fixtures\Factories;
4
5
use Zenstruck\Foundry\ModelFactory;
6
use Zenstruck\Foundry\Tests\Fixtures\Entity\Post;
7
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 */
11
class PostFactory extends ModelFactory
12
{
13
    public function published(): self
14
    {
15
        return $this->addState(function() {
16
            return ['published_at' => self::faker()->dateTime()];
17
        });
18
    }
19
20
    protected static function getClass(): string
21
    {
22
        return Post::class;
23
    }
24
25
    protected function getDefaults(): array
26
    {
27
        return [
28
            'title' => self::faker()->sentence(),
29
            'body' => self::faker()->sentence(),
30
        ];
31
    }
32
}
33