LaravelBitpay::Invoice()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Vrajroham\LaravelBitpay;
4
5
use BitPaySDK\Model\Bill\Item;
6
use BitPaySDK\Model\Currency;
7
use BitPaySDK\Model\Invoice\Buyer;
8
use BitPaySDK\Model\Invoice\Invoice;
9
use Vrajroham\LaravelBitpay\Traits\LaravelBitpayTrait;
10
11
class LaravelBitpay
12
{
13
    use LaravelBitpayTrait;
14
    public $client;
15
    public $config;
16
17
    /**
18
     * LaravelBitpay constructor.
19
     */
20
    public function __construct()
21
    {
22
        $this->authenticate();
23
    }
24
25
    /**
26
     * @return \BitPaySDK\Model\Invoice\Invoice
27
     */
28
    public static function Invoice(): Invoice
29
    {
30
        return new Invoice();
31
    }
32
33
    /**
34
     * @param \BitPaySDK\Model\Invoice\Invoice $invoice
35
     *
36
     * @return \BitPaySDK\Model\Invoice\Invoice
37
     */
38
    public static function createInvoice(Invoice $invoice): Invoice
39
    {
40
        if ('' == $invoice->getNotificationURL()) {
41
            $invoice->setNotificationURL(route('laravel-bitpay.webhook.capture'));
0 ignored issues
show
Bug introduced by
The function route was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

41
            $invoice->setNotificationURL(/** @scrutinizer ignore-call */ route('laravel-bitpay.webhook.capture'));
Loading history...
42
        }
43
44
        return (new self())->client->createInvoice($invoice);
45
    }
46
47
    /**
48
     * @return \BitPaySDK\Model\Bill\Item
49
     */
50
    public static function Item(): Item
51
    {
52
        return new Item();
53
    }
54
55
    /**
56
     * @return \BitPaySDK\Model\Invoice\Buyer
57
     */
58
    public static function Buyer(): Buyer
59
    {
60
        return new Buyer();
61
    }
62
63
    /**
64
     * @param null $code
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $code is correct as it would always require null to be passed?
Loading history...
65
     *
66
     * @return \Bitpay\Model\Currency
0 ignored issues
show
Bug introduced by
The type Bitpay\Model\Currency was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
67
     */
68
    public static function Currency($code = null): Currency
69
    {
70
        return new Currency($code);
0 ignored issues
show
Bug Best Practice introduced by
The expression return new BitPaySDK\Model\Currency($code) returns the type BitPaySDK\Model\Currency which is incompatible with the documented return type Bitpay\Model\Currency.
Loading history...
Unused Code introduced by
The call to BitPaySDK\Model\Currency::__construct() has too many arguments starting with $code. ( Ignorable by Annotation )

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

70
        return /** @scrutinizer ignore-call */ new Currency($code);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
71
    }
72
}
73