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:
parent
e79c5911b1
commit
7ba98cfe5d
28
src/Geometry/Pixel.php
Normal file
28
src/Geometry/Pixel.php
Normal 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;
|
||||
}
|
||||
}
|
23
tests/Geometry/PixelTest.php
Normal file
23
tests/Geometry/PixelTest.php
Normal 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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user