-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPaystackResourceProvider.php
More file actions
39 lines (33 loc) · 1.02 KB
/
PaystackResourceProvider.php
File metadata and controls
39 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace Matscode\Paystack\Providers;
use Matscode\Paystack\Exceptions\InvalidResourceException;
use Matscode\Paystack\ResourceRegistry;
use Matscode\Paystack\Utility\HTTP\HTTPClient;
/**
* Class PaystackResourceProvider
* @package Matscode\Paystack\Providers
*
* @property \Matscode\Paystack\Resources\Transaction $transaction
*/
abstract class PaystackResourceProvider
{
protected $HTTPClient, $callbackUrl = null;
public function __construct(string $secretKey)
{
$this->HTTPClient = new HTTPClient($secretKey);
}
/**
* @param $resourceName
* @return mixed
* @throws InvalidResourceException
* @ignore
*/
public function __get($resourceName)
{
if (array_key_exists($resourceName, ResourceRegistry::$registry)) {
return new ResourceRegistry::$registry[$resourceName]($this->HTTPClient);
} else {
throw new InvalidResourceException('\'' . $resourceName . '\' is not a valid resource in the ResourceRegistry');
}
}
}