Skip to content

Commit 8b46516

Browse files
committed
Change signature of ImageInterface::insert()
1 parent 6055814 commit 8b46516

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
- GreyscaleModifier::class was renamed to GrayscaleModifier::class
7171
- ImageInterface::greyscale() was renamed to ImageInterface::grayscale()
7272
- ColorInterface::isGreyscale() was renamed to ColorInterface::isGrayscale()
73-
- ImageInterface::place() was renamed to ImageInterface::insert, signature changed from `offset_x` to `x` and `offset_y` to `y`
73+
- ImageInterface::place() was renamed to ImageInterface::insert, signature changed from `offset_x` to `x` and `offset_y` to `y` and updated argument order
7474
- DrawableFactoryInterface::__invoke() was removed, use DrawableFactoryInterface::build or DrawableFactoryInterface::drawable()
7575
- FontFactory::__invoke() was removed, use FontFactory::build or FontFactory::font()
7676
- AnimationFactory::__invoke() was removed, use AnimationFactory::build or AnimationFactory::animation()

src/Image.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,12 +825,12 @@ public function trim(int $tolerance = 0): ImageInterface
825825
*/
826826
public function insert(
827827
mixed $element,
828-
string|Alignment $alignment = Alignment::TOP_LEFT,
829828
int $x = 0,
830829
int $y = 0,
830+
string|Alignment $alignment = Alignment::TOP_LEFT,
831831
int $opacity = 100
832832
): ImageInterface {
833-
return $this->modify(new InsertModifier($element, $alignment, $x, $y, $opacity));
833+
return $this->modify(new InsertModifier($element, $x, $y, $alignment, $opacity));
834834
}
835835

836836
/**

src/Interfaces/ImageInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,9 @@ public function trim(int $tolerance = 0): self;
477477
*/
478478
public function insert(
479479
mixed $element,
480-
string|Alignment $alignment = Alignment::TOP_LEFT,
481480
int $x = 0,
482481
int $y = 0,
482+
string|Alignment $alignment = Alignment::TOP_LEFT,
483483
int $opacity = 100
484484
): self;
485485

src/Modifiers/InsertModifier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class InsertModifier extends SpecializableModifier
1616
*/
1717
public function __construct(
1818
public mixed $element,
19-
public string|Alignment $alignment = Alignment::TOP_LEFT,
2019
public int $x = 0,
2120
public int $y = 0,
21+
public string|Alignment $alignment = Alignment::TOP_LEFT,
2222
public int $opacity = 100
2323
) {
2424
//

tests/Unit/Drivers/Gd/Modifiers/InsertModifierTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ public function testColorChange(): void
2121
{
2222
$image = $this->readTestImage('test.jpg');
2323
$this->assertEquals('febc44', $image->colorAt(300, 25)->toHex());
24-
$image->modify(new InsertModifier(Resource::create('circle.png')->path(), Alignment::TOP_RIGHT, 0, 0));
24+
$image->modify(new InsertModifier(Resource::create('circle.png')->path(), 0, 0, Alignment::TOP_RIGHT));
2525
$this->assertEquals('32250d', $image->colorAt(300, 25)->toHex());
2626
}
2727

2828
public function testColorChangeOpacityPng(): void
2929
{
3030
$image = $this->readTestImage('test.jpg');
3131
$this->assertEquals('febc44', $image->colorAt(300, 25)->toHex());
32-
$image->modify(new InsertModifier(Resource::create('circle.png')->path(), Alignment::TOP_RIGHT, 0, 0, 50));
32+
$image->modify(new InsertModifier(Resource::create('circle.png')->path(), 0, 0, Alignment::TOP_RIGHT, 50));
3333
$this->assertColor(152, 112, 40, 1, $image->colorAt(300, 25), tolerance: 1);
3434
$this->assertColor(255, 202, 107, 1, $image->colorAt(274, 5), tolerance: 1);
3535
}

tests/Unit/Drivers/Imagick/Modifiers/InsertModifierTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ public function testColorChange(): void
2121
{
2222
$image = $this->readTestImage('test.jpg');
2323
$this->assertEquals('febc44', $image->colorAt(300, 25)->toHex());
24-
$image->modify(new InsertModifier(Resource::create('circle.png')->path(), Alignment::TOP_RIGHT, 0, 0));
24+
$image->modify(new InsertModifier(Resource::create('circle.png')->path(), 0, 0, Alignment::TOP_RIGHT));
2525
$this->assertEquals('33260e', $image->colorAt(300, 25)->toHex());
2626
}
2727

2828
public function testColorChangeOpacityPng(): void
2929
{
3030
$image = $this->readTestImage('test.jpg');
3131
$this->assertEquals('febc44', $image->colorAt(300, 25)->toHex());
32-
$image->modify(new InsertModifier(Resource::create('circle.png')->path(), Alignment::TOP_RIGHT, 0, 0, 50));
32+
$image->modify(new InsertModifier(Resource::create('circle.png')->path(), 0, 0, Alignment::TOP_RIGHT, 50));
3333
$this->assertColor(152, 112, 40, 1, $image->colorAt(300, 25), tolerance: 1);
3434
$this->assertColor(255, 202, 107, 1, $image->colorAt(274, 5), tolerance: 1);
3535
}

0 commit comments

Comments
 (0)