diff --git a/src/SonsOfPHP/Bard/Tests/Console/Command/AddCommandTest.php b/src/SonsOfPHP/Bard/Tests/Console/Command/AddCommandTest.php
index 3d9e9647..601a3d81 100644
--- a/src/SonsOfPHP/Bard/Tests/Console/Command/AddCommandTest.php
+++ b/src/SonsOfPHP/Bard/Tests/Console/Command/AddCommandTest.php
@@ -21,7 +21,7 @@
use SonsOfPHP\Bard\Console\Command\SplitCommand;
use SonsOfPHP\Bard\Console\Command\UpdateCommand;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\File\Bard\AddPackageWorker;
+use SonsOfPHP\Bard\Operation\Bard\AddPackageOperation;
use Symfony\Component\Console\Tester\CommandTester;
#[Group('bard')]
@@ -38,7 +38,7 @@
#[UsesClass(SplitCommand::class)]
#[UsesClass(UpdateCommand::class)]
#[UsesClass(JsonFile::class)]
-#[UsesClass(AddPackageWorker::class)]
+#[UsesClass(AddPackageOperation::class)]
final class AddCommandTest extends TestCase
{
private Application $application;
diff --git a/src/SonsOfPHP/Bard/Tests/Console/Command/CopyCommandTest.php b/src/SonsOfPHP/Bard/Tests/Console/Command/CopyCommandTest.php
index fd2e8af0..e3248ca4 100644
--- a/src/SonsOfPHP/Bard/Tests/Console/Command/CopyCommandTest.php
+++ b/src/SonsOfPHP/Bard/Tests/Console/Command/CopyCommandTest.php
@@ -21,7 +21,7 @@
use SonsOfPHP\Bard\Console\Command\SplitCommand;
use SonsOfPHP\Bard\Console\Command\UpdateCommand;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\File\Bard\AddPackageWorker;
+use SonsOfPHP\Bard\Operation\Bard\AddPackageOperation;
use Symfony\Component\Console\Tester\CommandTester;
#[Group('bard')]
@@ -38,7 +38,7 @@
#[UsesClass(SplitCommand::class)]
#[UsesClass(UpdateCommand::class)]
#[UsesClass(JsonFile::class)]
-#[UsesClass(AddPackageWorker::class)]
+#[UsesClass(AddPackageOperation::class)]
final class CopyCommandTest extends TestCase
{
private Application $application;
diff --git a/src/SonsOfPHP/Bard/Tests/Console/Command/MergeCommandTest.php b/src/SonsOfPHP/Bard/Tests/Console/Command/MergeCommandTest.php
index ccb5696a..e7a25814 100644
--- a/src/SonsOfPHP/Bard/Tests/Console/Command/MergeCommandTest.php
+++ b/src/SonsOfPHP/Bard/Tests/Console/Command/MergeCommandTest.php
@@ -21,17 +21,17 @@
use SonsOfPHP\Bard\Console\Command\SplitCommand;
use SonsOfPHP\Bard\Console\Command\UpdateCommand;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\File\Composer\Package\Authors;
-use SonsOfPHP\Bard\Worker\File\Composer\Package\BranchAlias;
-use SonsOfPHP\Bard\Worker\File\Composer\Package\Funding;
-use SonsOfPHP\Bard\Worker\File\Composer\Package\Support;
-use SonsOfPHP\Bard\Worker\File\Composer\Root\ClearSection;
-use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateAutoloadDevSection;
-use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateAutoloadSection;
-use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateProvideSection;
-use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateReplaceSection;
-use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateRequireDevSection;
-use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateRequireSection;
+use SonsOfPHP\Bard\Operation\ClearSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Package\UpdateAuthorsSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Package\UpdateBranchAliasSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Package\UpdateFundingSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Package\UpdateSupportSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Root\UpdateAutoloadDevSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Root\UpdateAutoloadSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Root\UpdateProvideSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Root\UpdateReplaceSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Root\UpdateRequireDevSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Root\UpdateRequireSectionOperation;
use Symfony\Component\Console\Tester\CommandTester;
#[Group('bard')]
@@ -48,17 +48,17 @@
#[UsesClass(SplitCommand::class)]
#[UsesClass(UpdateCommand::class)]
#[UsesClass(JsonFile::class)]
-#[UsesClass(Authors::class)]
-#[UsesClass(BranchAlias::class)]
-#[UsesClass(Funding::class)]
-#[UsesClass(Support::class)]
-#[UsesClass(ClearSection::class)]
-#[UsesClass(UpdateAutoloadDevSection::class)]
-#[UsesClass(UpdateAutoloadSection::class)]
-#[UsesClass(UpdateProvideSection::class)]
-#[UsesClass(UpdateReplaceSection::class)]
-#[UsesClass(UpdateRequireSection::class)]
-#[UsesClass(UpdateRequireDevSection::class)]
+#[UsesClass(UpdateAuthorsSectionOperation::class)]
+#[UsesClass(UpdateBranchAliasSectionOperation::class)]
+#[UsesClass(UpdateFundingSectionOperation::class)]
+#[UsesClass(UpdateSupportSectionOperation::class)]
+#[UsesClass(ClearSectionOperation::class)]
+#[UsesClass(UpdateAutoloadDevSectionOperation::class)]
+#[UsesClass(UpdateAutoloadSectionOperation::class)]
+#[UsesClass(UpdateProvideSectionOperation::class)]
+#[UsesClass(UpdateReplaceSectionOperation::class)]
+#[UsesClass(UpdateRequireSectionOperation::class)]
+#[UsesClass(UpdateRequireDevSectionOperation::class)]
final class MergeCommandTest extends TestCase
{
private Application $application;
diff --git a/src/SonsOfPHP/Bard/Tests/Console/Command/PushCommandTest.php b/src/SonsOfPHP/Bard/Tests/Console/Command/PushCommandTest.php
index 2e71154b..9c4f4769 100644
--- a/src/SonsOfPHP/Bard/Tests/Console/Command/PushCommandTest.php
+++ b/src/SonsOfPHP/Bard/Tests/Console/Command/PushCommandTest.php
@@ -21,7 +21,7 @@
use SonsOfPHP\Bard\Console\Command\SplitCommand;
use SonsOfPHP\Bard\Console\Command\UpdateCommand;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\File\Bard\AddPackageWorker;
+use SonsOfPHP\Bard\Operation\Bard\AddPackageOperation;
use Symfony\Component\Console\Tester\CommandTester;
#[Group('bard')]
@@ -38,7 +38,7 @@
#[UsesClass(SplitCommand::class)]
#[UsesClass(UpdateCommand::class)]
#[UsesClass(JsonFile::class)]
-#[UsesClass(AddPackageWorker::class)]
+#[UsesClass(AddPackageOperation::class)]
final class PushCommandTest extends TestCase
{
private Application $application;
diff --git a/src/SonsOfPHP/Bard/Tests/Console/Command/ReleaseCommandTest.php b/src/SonsOfPHP/Bard/Tests/Console/Command/ReleaseCommandTest.php
index 0220aab7..796802ed 100644
--- a/src/SonsOfPHP/Bard/Tests/Console/Command/ReleaseCommandTest.php
+++ b/src/SonsOfPHP/Bard/Tests/Console/Command/ReleaseCommandTest.php
@@ -21,9 +21,9 @@
use SonsOfPHP\Bard\Console\Command\SplitCommand;
use SonsOfPHP\Bard\Console\Command\UpdateCommand;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\File\Bard\UpdateVersionWorker;
-use SonsOfPHP\Bard\Worker\File\Composer\Package\BranchAlias;
-use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateReplaceSection;
+use SonsOfPHP\Bard\Operation\Bard\UpdateVersionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Package\UpdateBranchAliasSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Root\UpdateReplaceSectionOperation;
use SonsOfPHP\Component\Version\Version;
use Symfony\Component\Console\Tester\CommandTester;
@@ -41,9 +41,9 @@
#[UsesClass(SplitCommand::class)]
#[UsesClass(UpdateCommand::class)]
#[UsesClass(JsonFile::class)]
-#[UsesClass(UpdateVersionWorker::class)]
-#[UsesClass(BranchAlias::class)]
-#[UsesClass(UpdateReplaceSection::class)]
+#[UsesClass(UpdateVersionOperation::class)]
+#[UsesClass(UpdateBranchAliasSectionOperation::class)]
+#[UsesClass(UpdateReplaceSectionOperation::class)]
#[UsesClass(Version::class)]
final class ReleaseCommandTest extends TestCase
{
diff --git a/src/SonsOfPHP/Bard/Tests/Worker/File/Bard/AddPackageWorkerTest.php b/src/SonsOfPHP/Bard/Tests/Operation/Bard/AddPackageOperationTest.php
similarity index 64%
rename from src/SonsOfPHP/Bard/Tests/Worker/File/Bard/AddPackageWorkerTest.php
rename to src/SonsOfPHP/Bard/Tests/Operation/Bard/AddPackageOperationTest.php
index 1d918a3d..3526693f 100644
--- a/src/SonsOfPHP/Bard/Tests/Worker/File/Bard/AddPackageWorkerTest.php
+++ b/src/SonsOfPHP/Bard/Tests/Operation/Bard/AddPackageOperationTest.php
@@ -2,27 +2,27 @@
declare(strict_types=1);
-namespace SonsOfPHP\Bard\Tests\File\Bard;
+namespace SonsOfPHP\Bard\Tests\Operation\Bard;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use SonsOfPHP\Bard\JsonFileInterface;
-use SonsOfPHP\Bard\Worker\File\Bard\AddPackageWorker;
-use SonsOfPHP\Bard\Worker\WorkerInterface;
+use SonsOfPHP\Bard\Operation\Bard\AddPackageOperation;
+use SonsOfPHP\Bard\Operation\OperationInterface;
#[Group('bard')]
-#[CoversClass(AddPackageWorker::class)]
-final class AddPackageWorkerTest extends TestCase
+#[CoversClass(AddPackageOperation::class)]
+final class AddPackageOperationTest extends TestCase
{
- private AddPackageWorker $worker;
+ private AddPackageOperation $worker;
private JsonFileInterface&MockObject $jsonFile;
protected function setUp(): void
{
- $this->worker = new AddPackageWorker([
+ $this->worker = new AddPackageOperation([
'path' => 'src/test',
'repository' => 'git@github.com:vendor/repo.git',
]);
@@ -32,7 +32,7 @@ protected function setUp(): void
public function testItImplementsCorrectInterface(): void
{
- $this->assertInstanceOf(WorkerInterface::class, $this->worker);
+ $this->assertInstanceOf(OperationInterface::class, $this->worker);
}
public function testItWillThrowExceptionWhenPackageAtSamePathExists(): void
@@ -53,13 +53,10 @@ public function testItWillAddNewPackage(): void
$this->jsonFile->expects($this->once())->method('setSection')
->with(
'packages',
- $this->callback(function ($packages): true {
- $this->assertSame([[
- 'path' => 'src/test',
- 'repository' => 'git@github.com:vendor/repo.git',
- ]], $packages);
- return true;
- })
+ $this->callback(fn($packages): true => [[
+ 'path' => 'src/test',
+ 'repository' => 'git@github.com:vendor/repo.git',
+ ]] === $packages)
)
;
diff --git a/src/SonsOfPHP/Bard/Tests/Operation/Bard/UpdateVersionOperationTest.php b/src/SonsOfPHP/Bard/Tests/Operation/Bard/UpdateVersionOperationTest.php
new file mode 100644
index 00000000..a74df6c5
--- /dev/null
+++ b/src/SonsOfPHP/Bard/Tests/Operation/Bard/UpdateVersionOperationTest.php
@@ -0,0 +1,49 @@
+version = $this->createMock(VersionInterface::class);
+ $this->worker = new UpdateVersionOperation($this->version);
+
+ $this->jsonFile = $this->createMock(JsonFileInterface::class);
+ }
+
+ public function testItImplementsCorrectInterface(): void
+ {
+ $this->assertInstanceOf(OperationInterface::class, $this->worker);
+ }
+
+ public function testItWillUpdateVersionSection(): void
+ {
+ $this->version->method('toString')->willReturn('1.2.3');
+ $this->jsonFile->expects($this->once())->method('setSection')->with(
+ 'version',
+ $this->callback(fn($version): true => '1.2.3' === $version)
+ );
+
+ $this->worker->apply($this->jsonFile);
+ }
+}
diff --git a/src/SonsOfPHP/Bard/src/Console/Command/AddCommand.php b/src/SonsOfPHP/Bard/src/Console/Command/AddCommand.php
index 8b0536c4..c257562b 100644
--- a/src/SonsOfPHP/Bard/src/Console/Command/AddCommand.php
+++ b/src/SonsOfPHP/Bard/src/Console/Command/AddCommand.php
@@ -4,7 +4,7 @@
namespace SonsOfPHP\Bard\Console\Command;
-use SonsOfPHP\Bard\Worker\File\Bard\AddPackageWorker;
+use SonsOfPHP\Bard\Operation\Bard\AddPackageOperation;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -45,7 +45,7 @@ protected function configure(): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
- $this->bardConfig = $this->bardConfig->with(new AddPackageWorker([
+ $this->bardConfig = $this->bardConfig->with(new AddPackageOperation([
'path' => $input->getArgument('path'),
'repository' => $input->getArgument('repository'),
]));
diff --git a/src/SonsOfPHP/Bard/src/Console/Command/MergeCommand.php b/src/SonsOfPHP/Bard/src/Console/Command/MergeCommand.php
index e8674120..ac6366fc 100644
--- a/src/SonsOfPHP/Bard/src/Console/Command/MergeCommand.php
+++ b/src/SonsOfPHP/Bard/src/Console/Command/MergeCommand.php
@@ -6,17 +6,17 @@
use RuntimeException;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\File\Composer\Package\Authors;
-use SonsOfPHP\Bard\Worker\File\Composer\Package\BranchAlias;
-use SonsOfPHP\Bard\Worker\File\Composer\Package\Funding;
-use SonsOfPHP\Bard\Worker\File\Composer\Package\Support;
-use SonsOfPHP\Bard\Worker\File\Composer\Root\ClearSection;
-use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateAutoloadDevSection;
-use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateAutoloadSection;
-use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateProvideSection;
-use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateReplaceSection;
-use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateRequireDevSection;
-use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateRequireSection;
+use SonsOfPHP\Bard\Operation\ClearSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Package\UpdateAuthorsSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Package\UpdateBranchAliasSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Package\UpdateFundingSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Package\UpdateSupportSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Root\UpdateAutoloadDevSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Root\UpdateAutoloadSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Root\UpdateProvideSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Root\UpdateReplaceSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Root\UpdateRequireDevSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Root\UpdateRequireSectionOperation;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -67,12 +67,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$rootComposerJsonFile = new JsonFile($input->getOption('working-dir') . '/composer.json');
// Clean out a few of the sections in root composer.json file
- $rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('autoload'));
- $rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('autoload-dev'));
- $rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('require'));
- $rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('require-dev'));
- $rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('replace'));
- $rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('provide'));
+ $rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSectionOperation('autoload'));
+ $rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSectionOperation('autoload-dev'));
+ $rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSectionOperation('require'));
+ $rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSectionOperation('require-dev'));
+ $rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSectionOperation('replace'));
+ $rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSectionOperation('provide'));
foreach ($this->bardConfig->getSection('packages') as $pkg) {
$pkgComposerFile = realpath($input->getOption('working-dir') . '/' . $pkg['path'] . '/composer.json');
@@ -90,19 +90,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln($this->getFormatterHelper()->formatSection('bard', sprintf('Merging "%s" into root composer.json', $pkgComposerJsonFile->getSection('name'))));
// Update root composer.json
- $rootComposerJsonFile = $rootComposerJsonFile->with(new UpdateReplaceSection($pkgComposerJsonFile));
- $rootComposerJsonFile = $rootComposerJsonFile->with(new UpdateRequireSection($pkgComposerJsonFile));
- $rootComposerJsonFile = $rootComposerJsonFile->with(new UpdateRequireDevSection($pkgComposerJsonFile));
- $rootComposerJsonFile = $rootComposerJsonFile->with(new UpdateAutoloadSection($pkgComposerJsonFile));
- $rootComposerJsonFile = $rootComposerJsonFile->with(new UpdateAutoloadDevSection($pkgComposerJsonFile));
- $rootComposerJsonFile = $rootComposerJsonFile->with(new UpdateProvideSection($pkgComposerJsonFile));
+ $rootComposerJsonFile = $rootComposerJsonFile->with(new UpdateReplaceSectionOperation($pkgComposerJsonFile));
+ $rootComposerJsonFile = $rootComposerJsonFile->with(new UpdateRequireSectionOperation($pkgComposerJsonFile));
+ $rootComposerJsonFile = $rootComposerJsonFile->with(new UpdateRequireDevSectionOperation($pkgComposerJsonFile));
+ $rootComposerJsonFile = $rootComposerJsonFile->with(new UpdateAutoloadSectionOperation($pkgComposerJsonFile));
+ $rootComposerJsonFile = $rootComposerJsonFile->with(new UpdateAutoloadDevSectionOperation($pkgComposerJsonFile));
+ $rootComposerJsonFile = $rootComposerJsonFile->with(new UpdateProvideSectionOperation($pkgComposerJsonFile));
// $rootComposerJsonFile = $rootComposerJsonFile->with(new Conflict($pkgComposerJsonFile));
// Update package composer.json
- $pkgComposerJsonFile = $pkgComposerJsonFile->with(new BranchAlias($rootComposerJsonFile));
- $pkgComposerJsonFile = $pkgComposerJsonFile->with(new Support($rootComposerJsonFile));
- $pkgComposerJsonFile = $pkgComposerJsonFile->with(new Authors($rootComposerJsonFile));
- $pkgComposerJsonFile = $pkgComposerJsonFile->with(new Funding($rootComposerJsonFile));
+ $pkgComposerJsonFile = $pkgComposerJsonFile->with(new UpdateBranchAliasSectionOperation($rootComposerJsonFile));
+ $pkgComposerJsonFile = $pkgComposerJsonFile->with(new UpdateSupportSectionOperation($rootComposerJsonFile));
+ $pkgComposerJsonFile = $pkgComposerJsonFile->with(new UpdateAuthorsSectionOperation($rootComposerJsonFile));
+ $pkgComposerJsonFile = $pkgComposerJsonFile->with(new UpdateFundingSectionOperation($rootComposerJsonFile));
if (!$isDryRun) {
file_put_contents($pkgComposerJsonFile->getFilename(), $pkgComposerJsonFile->toJson());
diff --git a/src/SonsOfPHP/Bard/src/Console/Command/ReleaseCommand.php b/src/SonsOfPHP/Bard/src/Console/Command/ReleaseCommand.php
index b92e9fef..7a9281f6 100644
--- a/src/SonsOfPHP/Bard/src/Console/Command/ReleaseCommand.php
+++ b/src/SonsOfPHP/Bard/src/Console/Command/ReleaseCommand.php
@@ -6,9 +6,9 @@
use RuntimeException;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\File\Bard\UpdateVersionWorker;
-use SonsOfPHP\Bard\Worker\File\Composer\Package\BranchAlias;
-use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateReplaceSection;
+use SonsOfPHP\Bard\Operation\Bard\UpdateVersionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Package\UpdateBranchAliasSectionOperation;
+use SonsOfPHP\Bard\Operation\Composer\Root\UpdateReplaceSectionOperation;
use SonsOfPHP\Component\Version\Version;
use SonsOfPHP\Component\Version\VersionInterface;
use Symfony\Component\Console\Input\ArrayInput;
@@ -157,7 +157,7 @@ private function updateReplace(InputInterface $input, OutputInterface $output):
foreach ($this->bardConfig->getSection('packages') as $pkg) {
$pkgComposerJsonFile = new JsonFile(realpath($input->getOption('working-dir') . '/' . $pkg['path'] . '/composer.json'));
$output->writeln($this->getFormatterHelper()->formatSection($pkgComposerJsonFile->getSection('name'), 'Updating root composer.json'));
- $this->rootComposerJsonFile = $this->rootComposerJsonFile->with(new UpdateReplaceSection($pkgComposerJsonFile));
+ $this->rootComposerJsonFile = $this->rootComposerJsonFile->with(new UpdateReplaceSectionOperation($pkgComposerJsonFile));
}
if (!$this->isDryRun) {
@@ -240,7 +240,7 @@ private function updateBranchAliasForPackages(InputInterface $input, OutputInter
foreach ($this->bardConfig->getSection('packages') as $pkg) {
$pkgComposerJsonFile = new JsonFile(realpath($input->getOption('working-dir') . '/' . $pkg['path'] . '/composer.json'));
- $pkgComposerJsonFile = $pkgComposerJsonFile->with(new BranchAlias($this->rootComposerJsonFile));
+ $pkgComposerJsonFile = $pkgComposerJsonFile->with(new UpdateBranchAliasSectionOperation($this->rootComposerJsonFile));
$output->writeln($this->getFormatterHelper()->formatSection($pkgComposerJsonFile->getSection('name'), 'Updated branch alias to "' . $branchAlias . '"'));
if (!$this->isDryRun) {
$pkgComposerJsonFile->save();
@@ -253,7 +253,7 @@ private function updateBranchAliasForPackages(InputInterface $input, OutputInter
private function updateBardConfigVersion(): void
{
$this->io->section('Updating version in bard.json');
- $this->bardConfig = $this->bardConfig->with(new UpdateVersionWorker($this->releaseVersion));
+ $this->bardConfig = $this->bardConfig->with(new UpdateVersionOperation($this->releaseVersion));
if (!$this->isDryRun) {
$this->bardConfig->save();
}
diff --git a/src/SonsOfPHP/Bard/src/Worker/File/Bard/AddPackageWorker.php b/src/SonsOfPHP/Bard/src/Operation/Bard/AddPackageOperation.php
similarity index 84%
rename from src/SonsOfPHP/Bard/src/Worker/File/Bard/AddPackageWorker.php
rename to src/SonsOfPHP/Bard/src/Operation/Bard/AddPackageOperation.php
index 503abc2b..d1dd9d52 100644
--- a/src/SonsOfPHP/Bard/src/Worker/File/Bard/AddPackageWorker.php
+++ b/src/SonsOfPHP/Bard/src/Operation/Bard/AddPackageOperation.php
@@ -2,15 +2,15 @@
declare(strict_types=1);
-namespace SonsOfPHP\Bard\Worker\File\Bard;
+namespace SonsOfPHP\Bard\Operation\Bard;
use SonsOfPHP\Bard\JsonFileInterface;
-use SonsOfPHP\Bard\Worker\WorkerInterface;
+use SonsOfPHP\Bard\Operation\OperationInterface;
/**
* @author Joshua Estes
*/
-final readonly class AddPackageWorker implements WorkerInterface
+final readonly class AddPackageOperation implements OperationInterface
{
public function __construct(
private array $config,
diff --git a/src/SonsOfPHP/Bard/src/Worker/File/Bard/UpdateVersionWorker.php b/src/SonsOfPHP/Bard/src/Operation/Bard/UpdateVersionOperation.php
similarity index 59%
rename from src/SonsOfPHP/Bard/src/Worker/File/Bard/UpdateVersionWorker.php
rename to src/SonsOfPHP/Bard/src/Operation/Bard/UpdateVersionOperation.php
index f54f52f0..a7ef4020 100644
--- a/src/SonsOfPHP/Bard/src/Worker/File/Bard/UpdateVersionWorker.php
+++ b/src/SonsOfPHP/Bard/src/Operation/Bard/UpdateVersionOperation.php
@@ -2,10 +2,10 @@
declare(strict_types=1);
-namespace SonsOfPHP\Bard\Worker\File\Bard;
+namespace SonsOfPHP\Bard\Operation\Bard;
-use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\WorkerInterface;
+use SonsOfPHP\Bard\JsonFileInterface;
+use SonsOfPHP\Bard\Operation\OperationInterface;
use SonsOfPHP\Component\Version\VersionInterface;
/**
@@ -16,11 +16,11 @@
*
* @author Joshua Estes
*/
-final readonly class UpdateVersionWorker implements WorkerInterface
+final readonly class UpdateVersionOperation implements OperationInterface
{
public function __construct(private VersionInterface $version) {}
- public function apply(JsonFile $bardJsonFile): JsonFile
+ public function apply(JsonFileInterface $bardJsonFile): JsonFileInterface
{
return $bardJsonFile->setSection('version', $this->version->toString());
}
diff --git a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/ClearSection.php b/src/SonsOfPHP/Bard/src/Operation/ClearSectionOperation.php
similarity index 68%
rename from src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/ClearSection.php
rename to src/SonsOfPHP/Bard/src/Operation/ClearSectionOperation.php
index 9708a06a..5ab2efa2 100644
--- a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/ClearSection.php
+++ b/src/SonsOfPHP/Bard/src/Operation/ClearSectionOperation.php
@@ -2,15 +2,14 @@
declare(strict_types=1);
-namespace SonsOfPHP\Bard\Worker\File\Composer\Root;
+namespace SonsOfPHP\Bard\Operation;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\WorkerInterface;
/**
* @author Joshua Estes
*/
-final readonly class ClearSection implements WorkerInterface
+final readonly class ClearSectionOperation implements OperationInterface
{
public function __construct(private string $section) {}
diff --git a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Package/Authors.php b/src/SonsOfPHP/Bard/src/Operation/Composer/Package/UpdateAuthorsSectionOperation.php
similarity index 70%
rename from src/SonsOfPHP/Bard/src/Worker/File/Composer/Package/Authors.php
rename to src/SonsOfPHP/Bard/src/Operation/Composer/Package/UpdateAuthorsSectionOperation.php
index abb9cd9a..a46181ae 100644
--- a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Package/Authors.php
+++ b/src/SonsOfPHP/Bard/src/Operation/Composer/Package/UpdateAuthorsSectionOperation.php
@@ -2,15 +2,15 @@
declare(strict_types=1);
-namespace SonsOfPHP\Bard\Worker\File\Composer\Package;
+namespace SonsOfPHP\Bard\Operation\Composer\Package;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\WorkerInterface;
+use SonsOfPHP\Bard\Operation\OperationInterface;
/**
* @author Joshua Estes
*/
-final readonly class Authors implements WorkerInterface
+final readonly class UpdateAuthorsSectionOperation implements OperationInterface
{
public function __construct(private JsonFile $rootComposerJsonFile) {}
diff --git a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Package/BranchAlias.php b/src/SonsOfPHP/Bard/src/Operation/Composer/Package/UpdateBranchAliasSectionOperation.php
similarity index 75%
rename from src/SonsOfPHP/Bard/src/Worker/File/Composer/Package/BranchAlias.php
rename to src/SonsOfPHP/Bard/src/Operation/Composer/Package/UpdateBranchAliasSectionOperation.php
index 0f16e6f3..ca5e0501 100644
--- a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Package/BranchAlias.php
+++ b/src/SonsOfPHP/Bard/src/Operation/Composer/Package/UpdateBranchAliasSectionOperation.php
@@ -2,15 +2,15 @@
declare(strict_types=1);
-namespace SonsOfPHP\Bard\Worker\File\Composer\Package;
+namespace SonsOfPHP\Bard\Operation\Composer\Package;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\WorkerInterface;
+use SonsOfPHP\Bard\Operation\OperationInterface;
/**
* @author Joshua Estes
*/
-final readonly class BranchAlias implements WorkerInterface
+final readonly class UpdateBranchAliasSectionOperation implements OperationInterface
{
public function __construct(private JsonFile $rootComposerJsonFile) {}
diff --git a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Package/Funding.php b/src/SonsOfPHP/Bard/src/Operation/Composer/Package/UpdateFundingSectionOperation.php
similarity index 70%
rename from src/SonsOfPHP/Bard/src/Worker/File/Composer/Package/Funding.php
rename to src/SonsOfPHP/Bard/src/Operation/Composer/Package/UpdateFundingSectionOperation.php
index 69f8d8ee..5e1d026d 100644
--- a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Package/Funding.php
+++ b/src/SonsOfPHP/Bard/src/Operation/Composer/Package/UpdateFundingSectionOperation.php
@@ -2,15 +2,15 @@
declare(strict_types=1);
-namespace SonsOfPHP\Bard\Worker\File\Composer\Package;
+namespace SonsOfPHP\Bard\Operation\Composer\Package;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\WorkerInterface;
+use SonsOfPHP\Bard\Operation\OperationInterface;
/**
* @author Joshua Estes
*/
-final readonly class Funding implements WorkerInterface
+final readonly class UpdateFundingSectionOperation implements OperationInterface
{
public function __construct(private JsonFile $rootComposerJsonFile) {}
diff --git a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Package/Support.php b/src/SonsOfPHP/Bard/src/Operation/Composer/Package/UpdateSupportSectionOperation.php
similarity index 78%
rename from src/SonsOfPHP/Bard/src/Worker/File/Composer/Package/Support.php
rename to src/SonsOfPHP/Bard/src/Operation/Composer/Package/UpdateSupportSectionOperation.php
index 5860ce6f..e97cf95d 100644
--- a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Package/Support.php
+++ b/src/SonsOfPHP/Bard/src/Operation/Composer/Package/UpdateSupportSectionOperation.php
@@ -2,15 +2,15 @@
declare(strict_types=1);
-namespace SonsOfPHP\Bard\Worker\File\Composer\Package;
+namespace SonsOfPHP\Bard\Operation\Composer\Package;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\WorkerInterface;
+use SonsOfPHP\Bard\Operation\OperationInterface;
/**
* @author Joshua Estes
*/
-final readonly class Support implements WorkerInterface
+final readonly class UpdateSupportSectionOperation implements OperationInterface
{
public function __construct(private JsonFile $rootComposerJsonFile) {}
diff --git a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateAutoloadDevSection.php b/src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateAutoloadDevSectionOperation.php
similarity index 91%
rename from src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateAutoloadDevSection.php
rename to src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateAutoloadDevSectionOperation.php
index 1ebbfd4f..c796c5ac 100644
--- a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateAutoloadDevSection.php
+++ b/src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateAutoloadDevSectionOperation.php
@@ -2,15 +2,15 @@
declare(strict_types=1);
-namespace SonsOfPHP\Bard\Worker\File\Composer\Root;
+namespace SonsOfPHP\Bard\Operation\Composer\Root;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\WorkerInterface;
+use SonsOfPHP\Bard\Operation\OperationInterface;
/**
* @author Joshua Estes
*/
-final readonly class UpdateAutoloadDevSection implements WorkerInterface
+final readonly class UpdateAutoloadDevSectionOperation implements OperationInterface
{
public function __construct(private JsonFile $pkgComposerJsonFile) {}
diff --git a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateAutoloadSection.php b/src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateAutoloadSectionOperation.php
similarity index 92%
rename from src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateAutoloadSection.php
rename to src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateAutoloadSectionOperation.php
index 0af2a253..bbb91e55 100644
--- a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateAutoloadSection.php
+++ b/src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateAutoloadSectionOperation.php
@@ -2,15 +2,15 @@
declare(strict_types=1);
-namespace SonsOfPHP\Bard\Worker\File\Composer\Root;
+namespace SonsOfPHP\Bard\Operation\Composer\Root;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\WorkerInterface;
+use SonsOfPHP\Bard\Operation\OperationInterface;
/**
* @author Joshua Estes
*/
-final readonly class UpdateAutoloadSection implements WorkerInterface
+final readonly class UpdateAutoloadSectionOperation implements OperationInterface
{
public function __construct(private JsonFile $pkgComposerJsonFile) {}
diff --git a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateProvideSection.php b/src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateProvideSectionOperation.php
similarity index 76%
rename from src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateProvideSection.php
rename to src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateProvideSectionOperation.php
index 5f18b062..63110c5e 100644
--- a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateProvideSection.php
+++ b/src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateProvideSectionOperation.php
@@ -2,15 +2,15 @@
declare(strict_types=1);
-namespace SonsOfPHP\Bard\Worker\File\Composer\Root;
+namespace SonsOfPHP\Bard\Operation\Composer\Root;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\WorkerInterface;
+use SonsOfPHP\Bard\Operation\OperationInterface;
/**
* @author Joshua Estes
*/
-final readonly class UpdateProvideSection implements WorkerInterface
+final readonly class UpdateProvideSectionOperation implements OperationInterface
{
public function __construct(private JsonFile $pkgComposerJsonFile) {}
@@ -21,6 +21,7 @@ public function apply(JsonFile $rootComposerJsonFile): JsonFile
return $rootComposerJsonFile;
}
+ /** @var array $rootProvideSection */
$rootProvideSection = $rootComposerJsonFile->getSection('provide');
foreach ($pkgProvideSection as $pkg => $version) {
diff --git a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateReplaceSection.php b/src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateReplaceSectionOperation.php
similarity index 70%
rename from src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateReplaceSection.php
rename to src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateReplaceSectionOperation.php
index ef9deb2f..d3bbf0da 100644
--- a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateReplaceSection.php
+++ b/src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateReplaceSectionOperation.php
@@ -2,20 +2,21 @@
declare(strict_types=1);
-namespace SonsOfPHP\Bard\Worker\File\Composer\Root;
+namespace SonsOfPHP\Bard\Operation\Composer\Root;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\WorkerInterface;
+use SonsOfPHP\Bard\Operation\OperationInterface;
/**
* @author Joshua Estes
*/
-final readonly class UpdateReplaceSection implements WorkerInterface
+final readonly class UpdateReplaceSectionOperation implements OperationInterface
{
public function __construct(private JsonFile $pkgComposerJsonFile) {}
public function apply(JsonFile $rootComposerJsonFile): JsonFile
{
+ /** @var array $rootReplace */
$rootReplace = $rootComposerJsonFile->getSection('replace');
$pkgName = $this->pkgComposerJsonFile->getSection('name');
diff --git a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateRequireDevSection.php b/src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateRequireDevSectionOperation.php
similarity index 71%
rename from src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateRequireDevSection.php
rename to src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateRequireDevSectionOperation.php
index e9b4f907..a3841f17 100644
--- a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateRequireDevSection.php
+++ b/src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateRequireDevSectionOperation.php
@@ -2,10 +2,10 @@
declare(strict_types=1);
-namespace SonsOfPHP\Bard\Worker\File\Composer\Root;
+namespace SonsOfPHP\Bard\Operation\Composer\Root;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\WorkerInterface;
+use SonsOfPHP\Bard\Operation\OperationInterface;
/**
* Updates the "require-dev" section in the primary composer.json file base on the
@@ -13,16 +13,23 @@
*
* @author Joshua Estes
*/
-final readonly class UpdateRequireDevSection implements WorkerInterface
+final readonly class UpdateRequireDevSectionOperation implements OperationInterface
{
public function __construct(private JsonFile $pkgComposerJsonFile) {}
public function apply(JsonFile $rootComposerJsonFile): JsonFile
{
+ /** @var array $rootRequireDev */
$rootRequireDev = $rootComposerJsonFile->getSection('require-dev');
- $pkgRequireDev = $this->pkgComposerJsonFile->getSection('require-dev');
- $rootRequire = $rootComposerJsonFile->getSection('require');
- $rootReplace = $rootComposerJsonFile->getSection('replace');
+
+ /** @var array $pkgRequireDev */
+ $pkgRequireDev = $this->pkgComposerJsonFile->getSection('require-dev');
+
+ /** @var array $rootRequire */
+ $rootRequire = $rootComposerJsonFile->getSection('require');
+
+ /** @var array $rootReplace */
+ $rootReplace = $rootComposerJsonFile->getSection('replace');
if (null === $pkgRequireDev) {
diff --git a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateRequireSection.php b/src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateRequireSectionOperation.php
similarity index 69%
rename from src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateRequireSection.php
rename to src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateRequireSectionOperation.php
index eee2891a..bff952ea 100644
--- a/src/SonsOfPHP/Bard/src/Worker/File/Composer/Root/UpdateRequireSection.php
+++ b/src/SonsOfPHP/Bard/src/Operation/Composer/Root/UpdateRequireSectionOperation.php
@@ -2,10 +2,10 @@
declare(strict_types=1);
-namespace SonsOfPHP\Bard\Worker\File\Composer\Root;
+namespace SonsOfPHP\Bard\Operation\Composer\Root;
use SonsOfPHP\Bard\JsonFile;
-use SonsOfPHP\Bard\Worker\WorkerInterface;
+use SonsOfPHP\Bard\Operation\OperationInterface;
/**
* Updates the "require" section in the root composer.json file base on the
@@ -13,15 +13,20 @@
*
* @author Joshua Estes
*/
-final readonly class UpdateRequireSection implements WorkerInterface
+final readonly class UpdateRequireSectionOperation implements OperationInterface
{
public function __construct(private JsonFile $pkgComposerJsonFile) {}
public function apply(JsonFile $rootComposerJsonFile): JsonFile
{
+ /** @var array $rootReplace */
$rootReplace = $rootComposerJsonFile->getSection('replace');
+
+ /** @var array $rootRequire */
$rootRequire = $rootComposerJsonFile->getSection('require');
- $pkgRequire = $this->pkgComposerJsonFile->getSection('require');
+
+ /** @var array $pkgRequire */
+ $pkgRequire = $this->pkgComposerJsonFile->getSection('require');
if (null === $pkgRequire) {
return $rootComposerJsonFile;
diff --git a/src/SonsOfPHP/Bard/src/Worker/WorkerInterface.php b/src/SonsOfPHP/Bard/src/Operation/OperationInterface.php
similarity index 58%
rename from src/SonsOfPHP/Bard/src/Worker/WorkerInterface.php
rename to src/SonsOfPHP/Bard/src/Operation/OperationInterface.php
index e04b9bb9..60dce5eb 100644
--- a/src/SonsOfPHP/Bard/src/Worker/WorkerInterface.php
+++ b/src/SonsOfPHP/Bard/src/Operation/OperationInterface.php
@@ -2,14 +2,12 @@
declare(strict_types=1);
-namespace SonsOfPHP\Bard\Worker;
+namespace SonsOfPHP\Bard\Operation;
/**
- * Use for various tasks.
- *
* @author Joshua Estes
*/
-interface WorkerInterface
+interface OperationInterface
{
// public function apply();
}