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

RefundSection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 2
rs 10
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\ReadView;
20
use Parthenon\Athena\Repository\CrudRepositoryInterface;
21
use Parthenon\Athena\Settings;
22
use Parthenon\Billing\Entity\Refund;
23
use Parthenon\Billing\Repository\RefundRepositoryInterface;
24
25
class RefundSection extends AbstractSection
26
{
27
    public function __construct(private RefundRepositoryInterface $refundRepository)
28
    {
29
    }
30
31
    public function getUrlTag(): string
32
    {
33
        return 'refund';
34
    }
35
36
    public function getRepository(): CrudRepositoryInterface
37
    {
38
        return $this->refundRepository;
39
    }
40
41
    public function getEntity()
42
    {
43
        return new Refund();
44
    }
45
46
    public function getMenuSection(): string
47
    {
48
        return 'Billing';
49
    }
50
51
    public function getMenuName(): string
52
    {
53
        return 'Refunds';
54
    }
55
56
    public function buildListView(ListView $listView): ListView
57
    {
58
        $listView->addField('customer', 'text')
59
            ->addField('amount', 'text')
60
            ->addField('currency', 'text')
61
            ->addField('createdAt', 'text');
62
63
        return $listView;
64
    }
65
66
    public function buildReadView(ReadView $readView): ReadView
67
    {
68
        $readView->section('Main')
69
            ->field('customer')
70
            ->field('amount')
71
            ->field('currency')
72
            ->field('createdAt')
73
            ->end();
74
75
        return $readView;
76
    }
77
78
    public function getSettings(): Settings
79
    {
80
        return new Settings(['create' => false, 'edit' => false]);
81
    }
82
}
83