From 6576ee73d6511de312ed299b837461039ebc48d2 Mon Sep 17 00:00:00 2001 From: DongJin Seo Date: Tue, 28 Aug 2018 16:40:19 +0900 Subject: [PATCH] Added $path of '.env' file to ChainFactory::api() and WalletFactory::api() --- src/Adapter/Settings/DotenvAdapter.php | 5 ++++- src/ChainFactory.php | 15 ++++++++++----- src/WalletFactory.php | 15 ++++++++++----- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/Adapter/Settings/DotenvAdapter.php b/src/Adapter/Settings/DotenvAdapter.php index 89d5111..dcb6c70 100644 --- a/src/Adapter/Settings/DotenvAdapter.php +++ b/src/Adapter/Settings/DotenvAdapter.php @@ -16,7 +16,10 @@ class DotenvAdapter implements SettingsInterface /** * DotenvAdapter constructor * - * @param Dotenv $client + * @param Dotenv $client + * @param bool $ifLoad + * @throws SettingsException + * @throws SettingsNotFoundException */ public function __construct(Dotenv $settings) { diff --git a/src/ChainFactory.php b/src/ChainFactory.php index 4af8953..902da29 100644 --- a/src/ChainFactory.php +++ b/src/ChainFactory.php @@ -19,15 +19,20 @@ class ChainFactory /** * Simple convenience factory which can be overloaded or used with defaults * - * @param string $env - * @param SettingsInterface|null $settings - * @param HttpInterface|null $http + * @param string|null $path + * @param string $env + * @param SettingsInterface|null $settings + * @param HttpInterface|null $http * * @return ChainController + * @throws Exception\SettingsException + * @throws Exception\SettingsNotFoundException + * @throws \ErrorException */ - public function api(string $env = '.env', SettingsInterface $settings = null, HttpInterface $http = null): ChainController + public function api(string $path = null, string $env = '.env', SettingsInterface $settings = null, HttpInterface $http = null): ChainController { - $settings = $settings ?? new DotenvAdapter(new Dotenv(dirname(__DIR__), $env)); + $path = $path ?? dirname(__DIR__); + $settings = $settings ?? new DotenvAdapter(new Dotenv($path, $env)); $http = $http ?? new CurlAdapter(new Curl); return new ChainController( diff --git a/src/WalletFactory.php b/src/WalletFactory.php index 9e0445e..96b1ff9 100644 --- a/src/WalletFactory.php +++ b/src/WalletFactory.php @@ -19,15 +19,20 @@ class WalletFactory /** * Simple convenience factory which can be overloaded or used with defaults * - * @param string $env - * @param SettingsInterface|null $settings - * @param HttpInterface|null $http + * @param string|null $path + * @param string $env + * @param SettingsInterface|null $settings + * @param HttpInterface|null $http * * @return WalletController + * @throws Exception\SettingsException + * @throws Exception\SettingsNotFoundException + * @throws \ErrorException */ - public function api(string $env = '.env', SettingsInterface $settings = null, HttpInterface $http = null): WalletController + public function api(string $path = null, string $env = '.env', SettingsInterface $settings = null, HttpInterface $http = null): WalletController { - $settings = $settings ?? new DotenvAdapter(new Dotenv(dirname(__DIR__), $env)); + $path = $path ?? dirname(__DIR__); + $settings = $settings ?? new DotenvAdapter(new Dotenv($path, $env)); $http = $http ?? new CurlAdapter(new Curl); return new WalletController(