Passed
Push — main ( 7d97d9...d69a4e )
by Iain
04:12
created

InvoiceGenerator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A generateInvoiceForPeriod() 0 2 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\Invoice;
16
17
use Parthenon\Billing\Entity\CustomerInterface;
18
use Parthenon\Billing\Entity\Invoice;
19
use Parthenon\Billing\Repository\PaymentRepositoryInterface;
20
use Parthenon\Billing\Repository\SubscriptionRepositoryInterface;
21
22
class InvoiceGenerator
23
{
24
    public function __construct(
25
        private SubscriptionRepositoryInterface $subscriptionRepository,
26
        private PaymentRepositoryInterface $paymentRepository
27
    ) {
28
    }
29
30
    public function generateInvoiceForPeriod(\DateTimeInterface $startDate, \DateTimeInterface $endDate, CustomerInterface $customer): Invoice
0 ignored issues
show
Unused Code introduced by
The parameter $startDate is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

30
    public function generateInvoiceForPeriod(/** @scrutinizer ignore-unused */ \DateTimeInterface $startDate, \DateTimeInterface $endDate, CustomerInterface $customer): Invoice

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $customer is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

30
    public function generateInvoiceForPeriod(\DateTimeInterface $startDate, \DateTimeInterface $endDate, /** @scrutinizer ignore-unused */ CustomerInterface $customer): Invoice

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $endDate is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

30
    public function generateInvoiceForPeriod(\DateTimeInterface $startDate, /** @scrutinizer ignore-unused */ \DateTimeInterface $endDate, CustomerInterface $customer): Invoice

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31
    {
32
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Parthenon\Billing\Entity\Invoice. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
33
}
34