Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#20 - php-di and guzzle updates #26

Merged
merged 1 commit into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"description": "A database production to sandbox utility to sanitize data.",
"type": "library",
"require": {
"php-di/php-di": "^5.4",
"php-di/php-di": "^6.0",
"aws/aws-sdk-php": "^3.19",
"symfony/yaml": ">=2.3",
"ericpoe/haystack": "^1.0",
"guzzlehttp/guzzle": "^6.2",
"guzzlehttp/guzzle": "^6.2|^7.0",
"psr/log": "^1.0",
"symfony/console": "^4.4",
"symfony/event-dispatcher": "^4.0"
Expand Down
38 changes: 20 additions & 18 deletions src/System/DependencyConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
* @package default
**/

declare(strict_types=1);

namespace Driver\System;

use DI;
use DI\Definition\Helper\DefinitionHelper;
use Driver\Engines\LocalConnectionInterface;
use Driver\Engines\MySql\Sandbox\Connection;
use Driver\Engines\MySql\Sandbox\Export;
use Driver\Engines\MySql\Sandbox\Import;
use Driver\Engines\RemoteConnectionInterface;
use Driver\Pipeline\Environment;
use Driver\Pipeline\Stage;
Expand All @@ -32,45 +33,46 @@
use Driver\Pipeline\Transport\Primary as TransportPrimary;
use Driver\System\Logs\LoggerInterface;
use Driver\System\Logs\Primary;
use Driver\System\DebugMode;
use Symfony\Component\Console\Application as ConsoleApplication;
use Symfony\Component\Console\Tester\ApplicationTester as ConsoleApplicationTester;

class DependencyConfig
{
private bool $isDebug = false;
private bool $isDebug;

public function __construct(bool $isDebug)
{
$this->isDebug = $isDebug;
}

public function get()
/**
* @return <string, DefinitionHelper>
*/
public function get(): array
{
$output = [
return [
LoggerInterface::class => DI\Factory(function() {
return new Primary();
}),
Environment\EnvironmentInterface::class => DI\factory([Environment\Primary::class, 'create']),
Environment\Factory::class => DI\object()->constructorParameter('type', Environment\Primary::class),
Environment\Factory::class => DI\autowire()->constructorParameter('type', Environment\Primary::class),
Stage\StageInterface::class => DI\factory([Stage\Primary::class, 'create']),
Stage\Factory::class => DI\object()->constructorParameter('type', Stage\Primary::class),
Stage\Factory::class => DI\autowire()->constructorParameter('type', Stage\Primary::class),
Span\SpanInterface::class => DI\factory([Span\Primary::class, 'create']),
Span\Factory::class => DI\object()->constructorParameter('type', Span\Primary::class),
TransportFactory::class => DI\object()->constructorParameter('type', TransportPrimary::class),
DebugMode::class => DI\object()->constructorParameter('debugMode', $this->isDebug),
RemoteConnectionInterface::class => DI\object(
Span\Factory::class => DI\autowire()->constructorParameter('type', Span\Primary::class),
TransportFactory::class => DI\autowire()->constructorParameter('type', TransportPrimary::class),
DebugMode::class => DI\create()->constructor($this->isDebug),
RemoteConnectionInterface::class => DI\autowire(
$this->isDebug ? DebugExternalConnection::class : Connection::class
),
LocalConnectionInterface::class => DI\object(
LocalConnectionInterface::class => DI\autowire(
\Driver\System\LocalConnectionLoader::class
)
];

return $output;
}

public function getForTests()
/**
* @return <string, DefinitionHelper>
*/
public function getForTests(): array
{
return array_merge(
$this->get(),
Expand Down