Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
18 / 18
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
TransactionFactory
100.00% covered (success)
100.00%
18 / 18
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 createPayment
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
1
 createRent
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Service;
6
7use App\Entity\PaymentMethod;
8use App\Entity\Store;
9use App\Entity\Transaction;
10use App\Entity\User;
11use App\Type\TransactionType;
12use DateTime;
13
14class TransactionFactory
15{
16    public function createPayment(
17        Store $store,
18        User $user,
19        PaymentMethod $method,
20        string $date,
21        int $recipeNo,
22        int $document,
23        int $depId,
24        string $amount,
25        string $comment,
26    ): Transaction {
27        return (new Transaction())
28            ->setDate(new DateTime($date))
29            ->setStore($store)
30            ->setUser($user)
31            ->setType(TransactionType::payment)
32            ->setMethod($method)
33            ->setRecipeNo($recipeNo)
34            ->setDocument($document)
35            ->setDepId($depId)
36            ->setAmount($amount)
37            ->setComment($comment);
38    }
39
40    public function createRent(
41        Store $store,
42        User $user,
43        PaymentMethod $method,
44        string $date,
45        string $amount,
46    ): Transaction {
47        return (new Transaction())
48            ->setDate(new DateTime($date))
49            ->setStore($store)
50            ->setUser($user)
51            ->setType(TransactionType::rent)
52            ->setMethod($method)
53            ->setAmount((string) (-(float) $amount));
54    }
55}