Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
LoanMother
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
3 / 3
4
100.00% covered (success)
100.00%
1 / 1
 active
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 returned
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
 create
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3// ╔════════════════════════════════════════════════════════════╗
4// ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║
5// ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com>     ║
6// ╚════════════════════════════════════════════════════════════╝
7
8declare(strict_types=1);
9
10namespace Tests\AppDemo\Fixture;
11
12use AppDemo\Loan\Domain\Loan;
13use AppDemo\Loan\Domain\LoanStatus;
14use DateTimeImmutable;
15use Phexium\Domain\Id\TimestampId;
16
17final class LoanMother
18{
19    public static function active(int $id = 1, int $userId = 100, int $bookId = 200): Loan
20    {
21        return self::create(
22            id: $id,
23            userId: $userId,
24            bookId: $bookId,
25            status: LoanStatus::Active
26        );
27    }
28
29    public static function returned(int $id = 1, int $userId = 100, int $bookId = 200): Loan
30    {
31        return self::create(
32            id: $id,
33            userId: $userId,
34            bookId: $bookId,
35            returnedAt: '2024-10-14',
36            status: LoanStatus::Returned
37        );
38    }
39
40    public static function create(
41        int $id = 1,
42        int $userId = 100,
43        int $bookId = 200,
44        string $borrowedAt = '2024-10-01',
45        string $dueAt = '2024-10-15',
46        ?string $returnedAt = null,
47        LoanStatus $status = LoanStatus::Active
48    ): Loan {
49        return new Loan(
50            new TimestampId($id),
51            new TimestampId($userId),
52            new TimestampId($bookId),
53            new DateTimeImmutable($borrowedAt),
54            new DateTimeImmutable($dueAt),
55            $returnedAt === null ? null : new DateTimeImmutable($returnedAt),
56            $status
57        );
58    }
59}