forked from easy-coding-standard/ecs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExitCodeResolver.php
More file actions
28 lines (22 loc) · 941 Bytes
/
ExitCodeResolver.php
File metadata and controls
28 lines (22 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
declare(strict_types=1);
namespace Symplify\EasyCodingStandard\Console\Output;
use Symplify\EasyCodingStandard\Console\ExitCode;
use Symplify\EasyCodingStandard\ValueObject\Configuration;
use Symplify\EasyCodingStandard\ValueObject\Error\ErrorAndDiffResult;
final class ExitCodeResolver
{
/**
* @return ExitCode::*
*/
public function resolve(ErrorAndDiffResult $errorAndDiffResult, Configuration $configuration): int
{
if ($errorAndDiffResult->getErrorCount() === 0 && $errorAndDiffResult->getFileDiffsCount() === 0) {
return ExitCode::SUCCESS;
}
if ($configuration->isFixer()) {
return $errorAndDiffResult->getErrorCount() === 0 ? ExitCode::SUCCESS : ExitCode::FAILURE;
}
return $errorAndDiffResult->getErrorCount() !== 0 || $errorAndDiffResult->getFileDiffsCount() !== 0 ? ExitCode::CHANGED_CODE_OR_FOUND_ERRORS : ExitCode::SUCCESS;
}
}