PaginationTypeFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 27
c 1
b 0
f 0
dl 0
loc 41
ccs 34
cts 34
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getExtraFields() 0 39 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Api\Output;
6
7
use Application\Api\Scalar\MoneyType;
8
use Application\Model\Bookable;
9
use Application\Model\Booking;
10
use Application\Model\TransactionLine;
11
use GraphQL\Type\Definition\Type;
12
13
/**
14
 * Create a Pagination type for the entity extracted from name.
15
 *
16
 * For example, if given "ActionPagination", it will create a Pagination
17
 * type for the Action entity.
18
 */
19
class PaginationTypeFactory extends \Ecodev\Felix\Api\Output\PaginationTypeFactory
20
{
21 1
    protected function getExtraFields(string $class): array
22
    {
23 1
        $fields = [];
24
25
        // Add specific total fields if needed
26 1
        if ($class === Booking::class) {
27 1
            $fields['totalParticipantCount'] = [
28 1
                'type' => Type::int(),
29 1
                'description' => 'The total count of participant',
30 1
            ];
31 1
            $fields['totalInitialPrice'] = [
32 1
                'type' => _types()->get(MoneyType::class),
33 1
                'description' => 'The total initial price',
34 1
            ];
35 1
            $fields['totalPeriodicPrice'] = [
36 1
                'type' => _types()->get(MoneyType::class),
37 1
                'description' => 'The total periodic price',
38 1
            ];
39 1
        } elseif ($class === Bookable::class) {
40 1
            $fields['totalPurchasePrice'] = [
41 1
                'type' => _types()->get(MoneyType::class),
42 1
                'description' => 'The total purchase price',
43 1
            ];
44 1
            $fields['totalInitialPrice'] = [
45 1
                'type' => _types()->get(MoneyType::class),
46 1
                'description' => 'The total initial price',
47 1
            ];
48 1
            $fields['totalPeriodicPrice'] = [
49 1
                'type' => _types()->get(MoneyType::class),
50 1
                'description' => 'The total periodic price',
51 1
            ];
52 1
        } elseif ($class === TransactionLine::class) {
53 1
            $fields['totalBalance'] = [
54 1
                'type' => _types()->get(MoneyType::class),
55 1
                'description' => 'The total balance',
56 1
            ];
57
        }
58
59 1
        return $fields;
60
    }
61
}
62