Skip to content

Commit ae1a77b

Browse files
committed
Configure using environment when constructor config is not specified
1 parent eee80f1 commit ae1a77b

File tree

7 files changed

+55
-55
lines changed

7 files changed

+55
-55
lines changed

Examples/CheckDomain.php

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
\Ease\Shared::init(['SUBREG_LOCATION', 'SUBREG_URI', 'SUBREG_LOGIN', 'SUBREG_PASSWORD'], '../.env');
2121

22-
$client = new Client(Client::env2conf(\Ease\Shared::instanced()->configuration));
22+
$client = new Client();
2323

2424
$unexistentDomain = strtolower(\Ease\Functions::randomString()).'.cz';
2525

@@ -30,38 +30,38 @@
3030
$response = $client->checkDomain($existingDomain);
3131
var_dump($response);
3232

33-
/**
34-
array(5) {
35-
'name' =>
36-
string(9) "spoje.net"
37-
'avail' =>
38-
int(0)
39-
'price' =>
40-
array(3) {
41-
'amount' =>
42-
string(6) "291.32"
43-
'premium' =>
44-
int(0)
45-
'currency' =>
46-
string(3) "CZK"
47-
}
48-
'price_renew' =>
49-
array(3) {
50-
'amount' =>
51-
string(6) "291.32"
52-
'premium' =>
53-
int(0)
54-
'currency' =>
55-
string(3) "CZK"
56-
}
57-
'price_transfer' =>
58-
array(3) {
59-
'amount' =>
60-
string(6) "291.32"
61-
'premium' =>
62-
int(0)
63-
'currency' =>
64-
string(3) "CZK"
65-
}
66-
}
67-
*/
33+
/**
34+
* array(5) {
35+
* 'name' =>
36+
* string(9) "spoje.net"
37+
* 'avail' =>
38+
* int(0)
39+
* 'price' =>
40+
* array(3) {
41+
* 'amount' =>
42+
* string(6) "291.32"
43+
* 'premium' =>
44+
* int(0)
45+
* 'currency' =>
46+
* string(3) "CZK"
47+
* }
48+
* 'price_renew' =>
49+
* array(3) {
50+
* 'amount' =>
51+
* string(6) "291.32"
52+
* 'premium' =>
53+
* int(0)
54+
* 'currency' =>
55+
* string(3) "CZK"
56+
* }
57+
* 'price_transfer' =>
58+
* array(3) {
59+
* 'amount' =>
60+
* string(6) "291.32"
61+
* 'premium' =>
62+
* int(0)
63+
* 'currency' =>
64+
* string(3) "CZK"
65+
* }
66+
* }.
67+
*/

Examples/DomainList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
\Ease\Shared::init(['SUBREG_LOCATION', 'SUBREG_URI', 'SUBREG_LOGIN', 'SUBREG_PASSWORD'], '../.env');
2121

22-
$client = new Client(Client::env2conf(\Ease\Shared::instanced()->configuration));
22+
$client = new Client();
2323

2424
$response = $client->call('Domains_List');
2525

Examples/GetDnsZone.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
'SUBREG_PASSWORD',
2525
], '../.env');
2626

27-
$client = new Client(Client::env2conf(\Ease\Shared::instanced()->configuration));
27+
$client = new Client();
2828
$client->login();
2929

3030
$response = $client->getDnsZone('vitexsoftware.com');

Examples/GetPriceList.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919

2020
\Ease\Shared::init(['SUBREG_LOCATION', 'SUBREG_URI', 'SUBREG_LOGIN', 'SUBREG_PASSWORD'], '../.env');
2121

22-
$client = new Client(Client::env2conf(\Ease\Shared::instanced()->configuration));
23-
22+
$client = new Client();
2423
print_r($client->getPricelist('KONCOVA'));
2524

2625
// print_r($client->pricelist());

Examples/RegisterDomain.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
\Ease\Shared::init(['SUBREG_LOCATION', 'SUBREG_URI', 'SUBREG_LOGIN', 'SUBREG_PASSWORD'], '../.env');
2121

22-
$client = new Client(Client::env2conf(\Ease\Shared::instanced()->configuration));
22+
$client = new Client();
2323

2424
$unexistentDomain = strtolower(\Ease\Sand::randomString()).'.cz';
2525

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ Konfigurace
3333

3434
Konfigurace se provádí nastavením následujících konstant:
3535

36-
```php
37-
/**
38-
* Write logs as:
39-
*/
40-
define('LOG_TYPE', 'syslog');
36+
```env
37+
EASE_LOGGER=syslog|console
38+
SUBREG_LOCATION=https://soap.subreg.cz/cmd.php
39+
SUBREG_URI=https://soap.subreg.cz/soap
40+
SUBREG_LOGIN=spojenetapi#spoje.net
41+
SUBREG_PASSWORD=KfbBPb?Uk6Q@%uca
4142
4243
```
4344

src/Subreg/Client.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ class Client extends \Ease\Molecule
6363

6464
/**
6565
* SubReg Client.
66-
*
67-
* @param array<string,string> $config
66+
*
67+
* @param array<string, string> $config
6868
*/
69-
public function __construct(array $config)
69+
public function __construct(array $config = [])
7070
{
71-
$this->config = $config;
71+
$this->config = $config ? self::env2conf(\Ease\Shared::instanced()->configuration) : $config;
7272
$this->soaper = new \SoapClient(
7373
null,
7474
[
75-
'location' => $config['location'],
76-
'uri' => $config['uri'],
75+
'location' => $this->config['location'],
76+
'uri' => $this->config['uri'],
7777
],
7878
);
7979
$this->setObjectName();
@@ -83,9 +83,9 @@ public function __construct(array $config)
8383
/**
8484
* Convert ENV keys to configuration.
8585
*
86-
* @param array<string,string> $env Env Data
87-
*
88-
* @return array<string,string>
86+
* @param array<string, string> $env Env Data
87+
*
88+
* @return array<string, string>
8989
*/
9090
public static function env2conf(array $env): array
9191
{

0 commit comments

Comments
 (0)