1
0
mirror of https://github.com/Intervention/image.git synced 2025-01-17 20:28:21 +01:00

Add Geometry\Pixel::class

This commit is contained in:
Oliver Vogel 2022-07-13 19:08:02 +02:00
parent e79c5911b1
commit 7ba98cfe5d
2 changed files with 51 additions and 0 deletions

28
src/Geometry/Pixel.php Normal file
View File

@ -0,0 +1,28 @@
<?php
namespace Intervention\Image\Geometry;
use Intervention\Image\Interfaces\ColorInterface;
class Pixel extends Point
{
public function __construct(
protected ColorInterface $background,
protected int $x,
protected int $y
) {
//
}
public function withBackground(ColorInterface $background): self
{
$this->background = $background;
return $this;
}
public function background(): ColorInterface
{
return $this->background;
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Intervention\Image\Tests\Geometry;
use Intervention\Image\Geometry\Pixel;
use Intervention\Image\Interfaces\ColorInterface;
use Intervention\Image\Tests\TestCase;
use Mockery;
/**
* @covers \Intervention\Image\Geometry\Pixel
*/
class PixelTest extends TestCase
{
public function testSetGetBackground(): void
{
$color = Mockery::mock(ColorInterface::class);
$pixel = new Pixel($color, 10, 12);
$result = $pixel->withBackground($color);
$this->assertInstanceOf(ColorInterface::class, $pixel->background());
$this->assertInstanceOf(Pixel::class, $result);
}
}