Completed
Push — master ( 3da051...184a5a )
by Orkhan
01:34
created

GoldenpayController::paymentResult()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Orkhanahmadov\LaravelGoldenpay\Http\Controllers;
4
5
use Orkhanahmadov\LaravelGoldenpay\Actions\PaymentEvent;
6
use Orkhanahmadov\LaravelGoldenpay\Goldenpay;
7
use Orkhanahmadov\LaravelGoldenpay\Http\Requests\Request;
8
use Orkhanahmadov\LaravelGoldenpay\Models\Payment;
9
10
abstract class GoldenpayController
11
{
12
    /**
13
     * @var PaymentEvent
14
     */
15
    private $event;
16
    /**
17
     * @var Goldenpay
18
     */
19
    protected $goldenpay;
20
    /**
21
     * @var Payment
22
     */
23
    protected $payment;
24
25
26
    /**
27
     * Controller constructor.
28
     *
29
     * @param Request $request
30
     * @param PaymentEvent $event
31
     * @param Goldenpay $goldenpay
32
     */
33
    public function __construct(
34
        Request $request,
35
        PaymentEvent $event,
36
        Goldenpay $goldenpay
37
    ) {
38
        $this->event = $event;
39
        $this->goldenpay = $goldenpay;
40
41
        $this->paymentResult($request);
42
    }
43
44
    /**
45
     * Checks payment result with "payment_key" query parameter.
46
     *
47
     * @param Request $request
48
     */
49
    final protected function paymentResult(Request $request): void
50
    {
51
        $this->payment = $this->goldenpay->result($request->query('payment_key'));
0 ignored issues
show
Bug introduced by
It seems like $request->query('payment_key') targeting Illuminate\Http\Concerns...ractsWithInput::query() can also be of type array or null; however, Orkhanahmadov\LaravelGoldenpay\Goldenpay::result() does only seem to accept object<Orkhanahmadov\Lar...\Models\Payment>|string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
52
    }
53
}
54