Skip to content

Commit

Permalink
Remove dependency to symfony/dotenv.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Aug 19, 2019
1 parent d1ae1b2 commit b6aa0e1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 31 deletions.
1 change: 0 additions & 1 deletion .env.dist

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -20,7 +20,6 @@
"require": {
"php": ">= 7.1.3",
"ext-json": "*",
"symfony/dotenv": "^4.3",
"symfony/http-client-contracts": "^1"
},
"require-dev": {
Expand All @@ -33,6 +32,7 @@
"phpspec/phpspec": "^5",
"rych/random": "^0.1.0",
"scrutinizer/ocular": "^1.5",
"symfony/dotenv": "^4.3",
"symfony/http-client": "^4.3"
},
"autoload": {
Expand Down
32 changes: 3 additions & 29 deletions src/RandomOrgAPI.php
@@ -1,12 +1,11 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace drupol\Yaroc;

use drupol\Yaroc\Http\Client;
use drupol\Yaroc\Plugin\ProviderInterface;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\HttpClient\NativeHttpClient;
use Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Contracts\HttpClient\ResponseInterface;
Expand Down Expand Up @@ -47,32 +46,7 @@ final class RandomOrgAPI implements RandomOrgAPIInterface
*/
public function __construct(HttpClientInterface $httpClient = null, array $configuration = [])
{
if (null === $httpClient) {
$httpClient = new NativeHttpClient(
[
'headers' => [
'User-Agent' => 'YAROC (http://github.com/drupol/yaroc)',
],
]
);
}

$this->httpClient = $httpClient;

$dotenv = new Dotenv();
$files = array_filter(
[
__DIR__ . '/../.env.dist',
__DIR__ . '/../.env',
],
'file_exists'
);
$dotenv->load(...$files);

if ($apikey = getenv('RANDOM_ORG_APIKEY')) {
$configuration += ['apiKey' => $apikey];
}

$this->httpClient = new Client($httpClient);
$this->configuration = $configuration;
}

Expand Down

0 comments on commit b6aa0e1

Please sign in to comment.