Skip to content

Commit 84dfd33

Browse files
committed
feat: allow getting billing config
1 parent e11d476 commit 84dfd33

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/Billing.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,31 @@ public function __construct($config = [])
4141
}
4242
}
4343

44+
/**
45+
* Get the billing config, or one key from it
46+
*
47+
* @param string|null $key Dot-notation key, eg `connections.stripe.currency`
48+
* @return mixed
49+
*/
50+
public function config(?string $key = null)
51+
{
52+
if ($key === null) {
53+
return $this->config;
54+
}
55+
56+
$value = $this->config;
57+
58+
foreach (explode('.', $key) as $segment) {
59+
if (!is_array($value) || !array_key_exists($segment, $value)) {
60+
return null;
61+
}
62+
63+
$value = $value[$segment];
64+
}
65+
66+
return $value;
67+
}
68+
4469
/**
4570
* Get a billing provider via name in config
4671
*

0 commit comments

Comments
 (0)