Skip to content

Commit e5a73c3

Browse files
committed
Improve Creator
1 parent 066a20e commit e5a73c3

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/PHPUnit/Cobertura/Formatter/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private function doRun(): int
7171
$this->consoleOutput->getFormatter()->setDecorated(!$this->commandLine->optionNoColor());
7272

7373
if ($this->commandLine->optionInit()) {
74-
(new Creator())->create();
74+
(new Creator($this->consoleOutput))->create();
7575

7676
return self::EXIT_CODE_OK;
7777
}

src/PHPUnit/Cobertura/Formatter/Config/File/Creator.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,23 @@
1212
namespace AndreyTech\PHPUnit\Cobertura\Formatter\Config\File;
1313

1414
use RuntimeException;
15+
use Symfony\Component\Console\Output\ConsoleOutput;
1516

1617
use function copy;
1718
use function file_exists;
1819
use function getcwd;
1920
use function sprintf;
2021

21-
final class Creator
22+
final readonly class Creator
2223
{
2324
private const string CONFIG_DIR = __DIR__ . '/../../../../../../config';
2425
private const string CONFIG_FILE = 'phpunit-cobertura-formatter.yml.dist';
2526

27+
public function __construct(
28+
private ConsoleOutput $consoleOutput
29+
) {
30+
}
31+
2632
public function create(): void
2733
{
2834
$source = sprintf('%s/%s', self::CONFIG_DIR, self::CONFIG_FILE);
@@ -34,10 +40,14 @@ public function create(): void
3440
);
3541
}
3642

37-
if (!@copy($source, $destination)) {
43+
if (!copy($source, $destination)) {
3844
throw new RuntimeException(
3945
sprintf('Failed to copy default config file to "%s".', $destination)
4046
);
4147
}
48+
49+
$this->consoleOutput->writeln(
50+
sprintf('Default config file created at "%s"', $destination)
51+
);
4252
}
4353
}

src/PHPUnit/Cobertura/Formatter/Config/File/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function validate(array $config): void
5656
*/
5757
private function loadSchema(): array
5858
{
59-
$schema = @file_get_contents(self::SCHEMA_FILE);
59+
$schema = file_get_contents(self::SCHEMA_FILE);
6060
if (false === $schema) {
6161
throw new RuntimeException(
6262
sprintf('Failed to load JSON schema file: "%s".', self::SCHEMA_FILE)

0 commit comments

Comments
 (0)