Skip to content

Commit 58c551b

Browse files
authored
Rename ItemProcessingErrorHandler into ErrorHandler (#114)
1 parent b3b5db5 commit 58c551b

15 files changed

+36
-34
lines changed

src/ErrorHandler/ItemProcessingErrorHandler.php renamed to src/ErrorHandler/ErrorHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Throwable;
1717
use Webmozarts\Console\Parallelization\Logger\Logger;
1818

19-
interface ItemProcessingErrorHandler
19+
interface ErrorHandler
2020
{
2121
public function handleError(string $item, Throwable $throwable, Logger $logger): void;
2222
}

src/ErrorHandler/ItemProcessingErrorHandlerLogger.php renamed to src/ErrorHandler/LoggingErrorHandler.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515

1616
use Throwable;
1717

18-
final class ItemProcessingErrorHandlerLogger implements ItemProcessingErrorHandler
18+
final class LoggingErrorHandler implements ErrorHandler
1919
{
20-
private ItemProcessingErrorHandler $decoratedErrorHandler;
20+
private ErrorHandler $decoratedErrorHandler;
2121

22-
public function __construct(ItemProcessingErrorHandler $decoratedErrorHandler)
22+
public function __construct(ErrorHandler $decoratedErrorHandler)
2323
{
2424
$this->decoratedErrorHandler = $decoratedErrorHandler;
2525
}

src/ErrorHandler/ResetContainerErrorHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Webmozarts\Console\Parallelization\Logger\Logger;
2121
use Webmozarts\Console\Parallelization\Symfony\ResettableContainerInterface;
2222

23-
final class ResetContainerErrorHandler implements ItemProcessingErrorHandler
23+
final class ResetContainerErrorHandler implements ErrorHandler
2424
{
2525
/**
2626
* @var (ContainerInterface&ResetInterface)|null

src/ParallelExecutor.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
use Throwable;
2828
use function usleep;
2929
use Webmozart\Assert\Assert;
30-
use Webmozarts\Console\Parallelization\ErrorHandler\ItemProcessingErrorHandler;
30+
use Webmozarts\Console\Parallelization\ErrorHandler\ErrorHandler;
3131
use Webmozarts\Console\Parallelization\Input\InputOptionsSerializer;
3232
use Webmozarts\Console\Parallelization\Input\ParallelizationInput;
3333
use Webmozarts\Console\Parallelization\Logger\Logger;
@@ -58,7 +58,7 @@ final class ParallelExecutor
5858

5959
private InputDefinition $commandDefinition;
6060

61-
private ItemProcessingErrorHandler $errorHandler;
61+
private ErrorHandler $errorHandler;
6262

6363
/**
6464
* @var resource
@@ -129,7 +129,7 @@ public function __construct(
129129
callable $getItemName,
130130
string $commandName,
131131
InputDefinition $commandDefinition,
132-
ItemProcessingErrorHandler $errorHandler,
132+
ErrorHandler $errorHandler,
133133
$childSourceStream,
134134
int $batchSize,
135135
int $segmentSize,

src/ParallelExecutorFactory.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Symfony\Component\Console\Input\InputDefinition;
2121
use Symfony\Component\Console\Input\InputInterface;
2222
use Symfony\Component\Console\Output\OutputInterface;
23-
use Webmozarts\Console\Parallelization\ErrorHandler\ItemProcessingErrorHandler;
23+
use Webmozarts\Console\Parallelization\ErrorHandler\ErrorHandler;
2424
use Webmozarts\Console\Parallelization\Process\PhpExecutableFinder;
2525
use Webmozarts\Console\Parallelization\Process\ProcessLauncherFactory;
2626
use Webmozarts\Console\Parallelization\Process\SymfonyProcessLauncherFactory;
@@ -46,7 +46,7 @@ final class ParallelExecutorFactory
4646

4747
private InputDefinition $commandDefinition;
4848

49-
private ItemProcessingErrorHandler $errorHandler;
49+
private ErrorHandler $errorHandler;
5050

5151
/**
5252
* @var resource
@@ -117,7 +117,7 @@ private function __construct(
117117
callable $getItemName,
118118
string $commandName,
119119
InputDefinition $commandDefinition,
120-
ItemProcessingErrorHandler $errorHandler,
120+
ErrorHandler $errorHandler,
121121
$childSourceStream,
122122
int $batchSize,
123123
int $segmentSize,
@@ -164,7 +164,7 @@ public static function create(
164164
callable $getItemName,
165165
string $commandName,
166166
InputDefinition $commandDefinition,
167-
ItemProcessingErrorHandler $errorHandler
167+
ErrorHandler $errorHandler
168168
): self {
169169
return new self(
170170
$fetchItems,

src/Parallelization.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
use Symfony\Component\Console\Output\OutputInterface;
2121
use Symfony\Component\Console\Terminal;
2222
use Symfony\Component\DependencyInjection\ContainerInterface;
23-
use Webmozarts\Console\Parallelization\ErrorHandler\ItemProcessingErrorHandler;
24-
use Webmozarts\Console\Parallelization\ErrorHandler\ItemProcessingErrorHandlerLogger;
23+
use Webmozarts\Console\Parallelization\ErrorHandler\ErrorHandler;
24+
use Webmozarts\Console\Parallelization\ErrorHandler\LoggingErrorHandler;
2525
use Webmozarts\Console\Parallelization\ErrorHandler\ResetContainerErrorHandler;
2626
use Webmozarts\Console\Parallelization\Input\ParallelizationInput;
2727
use Webmozarts\Console\Parallelization\Logger\DebugProgressBarFactory;
@@ -145,7 +145,7 @@ protected function getParallelExecutableFactory(
145145
callable $getItemName,
146146
string $commandName,
147147
InputDefinition $commandDefinition,
148-
ItemProcessingErrorHandler $errorHandler
148+
ErrorHandler $errorHandler
149149
): ParallelExecutorFactory {
150150
return ParallelExecutorFactory::create(
151151
$fetchItems,
@@ -157,9 +157,9 @@ protected function getParallelExecutableFactory(
157157
);
158158
}
159159

160-
protected function createItemErrorHandler(): ItemProcessingErrorHandler
160+
protected function createItemErrorHandler(): ErrorHandler
161161
{
162-
return new ItemProcessingErrorHandlerLogger(
162+
return new LoggingErrorHandler(
163163
new ResetContainerErrorHandler($this->getContainer()),
164164
);
165165
}

tests/ErrorHandler/NonResettableContainer.php renamed to tests/ErrorHandler/Container/NonResettableContainer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace Webmozarts\Console\Parallelization\ErrorHandler;
14+
namespace Webmozarts\Console\Parallelization\ErrorHandler\Container;
1515

1616
use DomainException;
1717
use Psr\Container\ContainerInterface;

tests/ErrorHandler/ResetContainerErrorhandlerTest.php renamed to tests/ErrorHandler/Container/ResetContainerErrorhandlerTest.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace Webmozarts\Console\Parallelization\ErrorHandler;
14+
namespace Webmozarts\Console\Parallelization\ErrorHandler\Container;
1515

1616
use Error;
1717
use PHPUnit\Framework\TestCase;
18+
use Webmozarts\Console\Parallelization\ErrorHandler\ErrorHandler;
19+
use Webmozarts\Console\Parallelization\ErrorHandler\ResetContainerErrorHandler;
1820
use Webmozarts\Console\Parallelization\Logger\FakeLogger;
1921

2022
/**
@@ -47,7 +49,7 @@ public function test_it_resets_the_container_if_the_container_is_resettable(): v
4749
self::assertTrue($container->reset);
4850
}
4951

50-
private static function handleError(ItemProcessingErrorHandler $errorHandler): void
52+
private static function handleError(ErrorHandler $errorHandler): void
5153
{
5254
$errorHandler->handleError(
5355
'item0',

tests/ErrorHandler/ResettableContainer.php renamed to tests/ErrorHandler/Container/ResettableContainer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace Webmozarts\Console\Parallelization\ErrorHandler;
14+
namespace Webmozarts\Console\Parallelization\ErrorHandler\Container;
1515

1616
use DomainException;
1717
use Psr\Container\ContainerInterface;

tests/ErrorHandler/DummyErrorHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Throwable;
1818
use Webmozarts\Console\Parallelization\Logger\Logger;
1919

20-
final class DummyErrorHandler implements ItemProcessingErrorHandler
20+
final class DummyErrorHandler implements ErrorHandler
2121
{
2222
public array $calls = [];
2323

tests/ErrorHandler/FakeErrorHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Throwable;
1818
use Webmozarts\Console\Parallelization\Logger\Logger;
1919

20-
final class FakeErrorHandler implements ItemProcessingErrorHandler
20+
final class FakeErrorHandler implements ErrorHandler
2121
{
2222
public function handleError(string $item, Throwable $throwable, Logger $logger): void
2323
{

tests/ErrorHandler/ItemProcessingErrorHandlerLoggerTest.php renamed to tests/ErrorHandler/LoggingErrorHandlerTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
use Webmozarts\Console\Parallelization\Logger\Logger;
2020

2121
/**
22-
* @covers \Webmozarts\Console\Parallelization\ErrorHandler\ItemProcessingErrorHandlerLogger
22+
* @covers \Webmozarts\Console\Parallelization\ErrorHandler\LoggingErrorHandler
2323
*/
24-
final class ItemProcessingErrorHandlerLoggerTest extends TestCase
24+
final class LoggingErrorHandlerTest extends TestCase
2525
{
2626
use ProphecyTrait;
2727

@@ -30,13 +30,13 @@ public function test_it_logs_and_forwards_the_error_handling_to_the_decorated_er
3030
$item = 'item1';
3131
$throwable = new Error('An error occurred.');
3232

33-
$decoratedErrorHandlerProphecy = $this->prophesize(ItemProcessingErrorHandler::class);
33+
$decoratedErrorHandlerProphecy = $this->prophesize(ErrorHandler::class);
3434
$decoratedErrorHandler = $decoratedErrorHandlerProphecy->reveal();
3535

3636
$loggerProphecy = $this->prophesize(Logger::class);
3737
$logger = $loggerProphecy->reveal();
3838

39-
$errorHandler = new ItemProcessingErrorHandlerLogger($decoratedErrorHandler);
39+
$errorHandler = new LoggingErrorHandler($decoratedErrorHandler);
4040

4141
$decoratedErrorHandlerProphecy
4242
->handleError($item, $throwable, $logger)

tests/Fixtures/Command/ImportMoviesCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
use Symfony\Component\Console\Logger\ConsoleLogger;
2424
use Symfony\Component\Console\Output\OutputInterface;
2525
use Symfony\Component\Console\Terminal;
26-
use Webmozarts\Console\Parallelization\ErrorHandler\ItemProcessingErrorHandler;
26+
use Webmozarts\Console\Parallelization\ErrorHandler\ErrorHandler;
2727
use Webmozarts\Console\Parallelization\Integration\TestDebugProgressBarFactory;
2828
use Webmozarts\Console\Parallelization\Integration\TestLogger;
2929
use Webmozarts\Console\Parallelization\Logger\Logger;
@@ -78,7 +78,7 @@ protected function getParallelExecutableFactory(
7878
callable $getItemName,
7979
string $commandName,
8080
InputDefinition $commandDefinition,
81-
ItemProcessingErrorHandler $errorHandler
81+
ErrorHandler $errorHandler
8282
): ParallelExecutorFactory {
8383
return $this
8484
->getOriginalParallelExecutableFactory(

tests/Fixtures/Command/NoSubProcessCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use Symfony\Component\Console\Logger\ConsoleLogger;
2222
use Symfony\Component\Console\Output\OutputInterface;
2323
use Symfony\Component\Console\Terminal;
24-
use Webmozarts\Console\Parallelization\ErrorHandler\ItemProcessingErrorHandler;
24+
use Webmozarts\Console\Parallelization\ErrorHandler\ErrorHandler;
2525
use Webmozarts\Console\Parallelization\Integration\TestDebugProgressBarFactory;
2626
use Webmozarts\Console\Parallelization\Logger\Logger;
2727
use Webmozarts\Console\Parallelization\Logger\StandardLogger;
@@ -63,7 +63,7 @@ protected function getParallelExecutableFactory(
6363
callable $getItemName,
6464
string $commandName,
6565
InputDefinition $commandDefinition,
66-
ItemProcessingErrorHandler $errorHandler
66+
ErrorHandler $errorHandler
6767
): ParallelExecutorFactory {
6868
return $this
6969
->getOriginalParallelExecutableFactory(

tests/ParallelExecutorTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
use Symfony\Component\Console\Output\NullOutput;
3434
use Symfony\Component\Console\Output\OutputInterface;
3535
use Webmozarts\Console\Parallelization\ErrorHandler\DummyErrorHandler;
36+
use Webmozarts\Console\Parallelization\ErrorHandler\ErrorHandler;
3637
use Webmozarts\Console\Parallelization\ErrorHandler\FakeErrorHandler;
37-
use Webmozarts\Console\Parallelization\ErrorHandler\ItemProcessingErrorHandler;
3838
use Webmozarts\Console\Parallelization\Input\ParallelizationInput;
3939
use Webmozarts\Console\Parallelization\Logger\DummyLogger;
4040
use Webmozarts\Console\Parallelization\Logger\FakeLogger;
@@ -1042,7 +1042,7 @@ private static function mainProcessWithoutChildProcessLaunchedProvider(): iterab
10421042
*/
10431043
private static function createChildProcessExecutor(
10441044
callable $runSingleCommand,
1045-
ItemProcessingErrorHandler $errorHandler,
1045+
ErrorHandler $errorHandler,
10461046
$childSourceStream,
10471047
int $batchSize,
10481048
callable $runBeforeFirstCommand,
@@ -1087,7 +1087,7 @@ private static function createChildProcessExecutor(
10871087
private static function createMainProcessExecutor(
10881088
array $items,
10891089
callable $runSingleCommand,
1090-
ItemProcessingErrorHandler $errorHandler,
1090+
ErrorHandler $errorHandler,
10911091
int $batchSize,
10921092
int $segmentSize,
10931093
callable $runBeforeFirstCommand,

0 commit comments

Comments
 (0)