Skip to content

Commit

Permalink
Instantiate the log provider through the static create function
Browse files Browse the repository at this point in the history
  • Loading branch information
scheb committed Dec 29, 2020
1 parent 9fee281 commit 92f96b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/src/Tombstone/LogProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@

class LogProvider implements LogProviderInterface
{
public function __construct(array $config, ConsoleOutputInterface $consoleOutput, bool $isCalled)
{
}

public static function create(array $config, ConsoleOutputInterface $consoleOutput): LogProviderInterface
{
return new self();
// Ensure the class was instantiated through the create method
return new self($config, $consoleOutput, true);
}

public function getVampires(): iterable
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/Cli/AnalyzeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private function createLogCollector(array $config, VampireIndex $vampireIndex):
}

/** @var LogProviderInterface $logReader */
$logReader = $reflectionClass->newInstance();
$logReader = $reflectionClass->getMethod('create')->invoke(null, $config, $this->output);
$logProviders[] = $logReader;
}

Expand Down

0 comments on commit 92f96b1

Please sign in to comment.