Passed
Push — main ( 0705b8...350a1e )
by Iain
04:41
created

PaymentSection   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 45
rs 10
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A getRepository() 0 3 1
A getEntity() 0 3 1
A getUrlTag() 0 3 1
A getSettings() 0 3 1
A getMenuName() 0 3 1
A getMenuSection() 0 3 1
A buildListView() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright Iain Cambridge 2020-2023.
7
 *
8
 * Use of this software is governed by the Business Source License included in the LICENSE file and at https://getparthenon.com/docs/next/license.
9
 *
10
 * Change Date: TBD ( 3 years after 2.2.0 release )
11
 *
12
 * On the date above, in accordance with the Business Source License, use of this software will be governed by the open source license specified in the LICENSE file.
13
 */
14
15
namespace Parthenon\Billing\Athena;
16
17
use Parthenon\Athena\AbstractSection;
18
use Parthenon\Athena\ListView;
19
use Parthenon\Athena\Repository\CrudRepositoryInterface;
20
use Parthenon\Athena\Settings;
21
use Parthenon\Billing\Entity\Payment;
22
use Parthenon\Billing\Repository\PaymentRepositoryInterface;
23
24
class PaymentSection extends AbstractSection
25
{
26
    public function __construct(private PaymentRepositoryInterface $paymentRepository)
27
    {
28
    }
29
30
    public function getUrlTag(): string
31
    {
32
        return 'billing-payments';
33
    }
34
35
    public function getRepository(): CrudRepositoryInterface
36
    {
37
        return $this->paymentRepository;
38
    }
39
40
    public function getEntity()
41
    {
42
        return new Payment();
43
    }
44
45
    public function getMenuSection(): string
46
    {
47
        return 'Billing';
48
    }
49
50
    public function getMenuName(): string
51
    {
52
        return 'Payments';
53
    }
54
55
    public function buildListView(ListView $listView): ListView
56
    {
57
        $listView
58
            ->addField('customer', 'entity')
59
            ->addField('provider', 'text')
60
            ->addField('moneyAmount', 'text')
61
            ->addField('completed', 'boolean');
62
63
        return $listView;
64
    }
65
66
    public function getSettings(): Settings
67
    {
68
        return new Settings(['edit' => false, 'create' => false]);
69
    }
70
}
71