Completed
Push — master ( bd50f4...3ec705 )
by Orkhan
01:33
created

PaymentEvent::__construct()   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\Actions;
4
5
use Illuminate\Contracts\Config\Repository;
6
use Illuminate\Contracts\Events\Dispatcher;
7
use Orkhanahmadov\LaravelGoldenpay\Events\PaymentCheckedEvent;
8
use Orkhanahmadov\LaravelGoldenpay\Models\Payment;
9
10
class PaymentEvent
11
{
12
    /**
13
     * @var Repository
14
     */
15
    private $config;
16
17
    /**
18
     * Event constructor.
19
     *
20
     * @param Repository $config
21
     */
22
    public function __construct(Repository $config)
23
    {
24
        $this->config = $config;
25
    }
26
27
    /**
28
     * Fires event with given Payment instance.
29
     *
30
     * @param string $name
31
     * @param Payment $payment
32
     */
33
    public function execute(string $name, Payment $payment): void
34
    {
35
        $event = $this->config->get($name);
36
37
        $event::dispatch($payment);
38
    }
39
}
40