PaginationTypeFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 20
dl 0
loc 31
ccs 25
cts 25
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getExtraFields() 0 29 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Api\Output;
6
7
use Application\Model\Order;
8
use Application\Model\OrderLine;
9
use GraphQL\Type\Definition\Type;
10
11
/**
12
 * Create a Pagination type for the entity extracted from name.
13
 *
14
 * For example, if given "ActionPagination", it will create a Pagination
15
 * type for the Action entity.
16
 */
17
class PaginationTypeFactory extends \Ecodev\Felix\Api\Output\PaginationTypeFactory
18
{
19 1
    protected function getExtraFields(string $class): array
20
    {
21 1
        $fields = [];
22
        // Add specific total fields if needed
23 1
        if ($class === OrderLine::class) {
24 1
            $fields['totalBalanceCHF'] = [
25 1
                'type' => _types()->get('CHF'),
26 1
                'description' => 'The total balance',
27 1
            ];
28 1
            $fields['totalBalanceEUR'] = [
29 1
                'type' => _types()->get('EUR'),
30 1
                'description' => 'The total balance',
31 1
            ];
32 1
            $fields['totalQuantity'] = [
33 1
                'type' => Type::int(),
34 1
                'description' => 'The total quantity',
35 1
            ];
36 1
        } elseif ($class === Order::class) {
37 1
            $fields['totalBalanceCHF'] = [
38 1
                'type' => _types()->get('CHF'),
39 1
                'description' => 'The total balance',
40 1
            ];
41 1
            $fields['totalBalanceEUR'] = [
42 1
                'type' => _types()->get('EUR'),
43 1
                'description' => 'The total balance',
44 1
            ];
45
        }
46
47 1
        return $fields;
48
    }
49
}
50