Skip to content

Commit

Permalink
Fix: Switch order of parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Sep 3, 2023
1 parent fb0d147 commit 606e81f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Faker/Container/ContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class ContainerBuilder
*
* @throws \InvalidArgumentException
*/
public function add($value, string $name): self
public function add(string $name, $value): self
{
if (!is_string($value) && !is_callable($value) && !is_object($value)) {
throw new \InvalidArgumentException(sprintf(
Expand Down Expand Up @@ -71,7 +71,7 @@ public static function getDefault(): ContainerInterface
$instance = new self();

foreach (self::defaultExtensions() as $id => $definition) {
$instance->add($definition, $id);
$instance->add($id, $definition);
}

return $instance->build();
Expand Down
14 changes: 7 additions & 7 deletions test/Faker/Extension/ContainerBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testAddRejectsInvalidValue($value): void
ContainerBuilder::class,
));

$containerBuilder->add($value, 'foo');
$containerBuilder->add('foo', $value);
}

/**
Expand Down Expand Up @@ -71,7 +71,7 @@ public function testBuild(): void
{
$builder = new ContainerBuilder();

$builder->add(File::class, 'foo');
$builder->add('foo', File::class);

$container = $builder->build();

Expand All @@ -82,8 +82,8 @@ public function testBuildWithDuplicates(): void
{
$builder = new ContainerBuilder();

$builder->add(File::class, 'foo');
$builder->add(File::class, 'foo');
$builder->add('foo', File::class);
$builder->add('foo', File::class);

$container = $builder->build();

Expand All @@ -94,7 +94,7 @@ public function testBuildWithObject(): void
{
$builder = new ContainerBuilder();

$builder->add(new File(), 'foo');
$builder->add('foo', new File());

$container = $builder->build();

Expand All @@ -105,9 +105,9 @@ public function testBuildWithCallable(): void
{
$builder = new ContainerBuilder();

$builder->add(static function () {
$builder->add('foo', static function () {
return new File();
}, 'foo');
});

$container = $builder->build();

Expand Down
2 changes: 1 addition & 1 deletion test/Faker/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function testFormatTransfersArgumentsToFormatter(): void
public function testFormatterCallsGenerator(): void
{
$builder = new ContainerBuilder();
$builder->add(Blood::class, BloodExtension::class);
$builder->add(BloodExtension::class, Blood::class);
$faker = new Generator($builder->build());

$output = $faker->format('bloodType');
Expand Down

0 comments on commit 606e81f

Please sign in to comment.