Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze authored and github-actions[bot] committed Jul 26, 2024
1 parent 14f93e4 commit 9c3ec31
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/Drivers/Concerns/AddsWatermark.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function watermark(
int $alpha = 100): static
{
if (is_string($watermarkImage)) {
$watermarkImage = (new self())->loadFile($watermarkImage);
$watermarkImage = (new self)->loadFile($watermarkImage);
}

$this->ensureNumberBetween($alpha, 0, 100, 'alpha');
Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/Gd/GdDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ public function insert(
): static {
$this->ensureNumberBetween($alpha, 0, 100, 'alpha');
if (is_string($otherImage)) {
$otherImage = (new self())->loadFile($otherImage);
$otherImage = (new self)->loadFile($otherImage);
}

$imageSize = $this->getSize()->align($position, $x, $y);
Expand Down
18 changes: 9 additions & 9 deletions src/Drivers/Imagick/ImagickDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ class ImagickDriver implements ImageDriver
public function new(int $width, int $height, ?string $backgroundColor = null): static
{
$color = new ImagickColor($backgroundColor);
$image = new Imagick();
$image = new Imagick;

$image->newImage($width, $height, $color->getPixel(), 'png');
$image->setType(Imagick::IMGTYPE_UNDEFINED);
$image->setImageType(Imagick::IMGTYPE_UNDEFINED);
$image->setColorspace(Imagick::COLORSPACE_UNDEFINED);

return (new self())->setImage($image);
return (new self)->setImage($image);
}

protected function setImage(Imagick $image): static
Expand Down Expand Up @@ -278,7 +278,7 @@ public function save(?string $path = null): static
$image->setFormat($format);
}
}

if ($this->isAnimated()) {
$image = $this->image->deconstructImages();
$image->writeImages($path, true);
Expand Down Expand Up @@ -505,7 +505,7 @@ public function insert(
): static {
$this->ensureNumberBetween($alpha, 0, 100, 'alpha');
if (is_string($otherImage)) {
$otherImage = (new self())->loadFile($otherImage);
$otherImage = (new self)->loadFile($otherImage);
}

$otherImage->image->setImageOrientation(Imagick::ORIENTATION_UNDEFINED);
Expand Down Expand Up @@ -592,9 +592,9 @@ public function border(int $width, BorderType $type, string $color = '000000'):
}

if ($type === BorderType::Overlay) {
$shape = new ImagickDraw();
$shape = new ImagickDraw;

$backgroundColor = new ImagickColor();
$backgroundColor = new ImagickColor;
$shape->setFillColor($backgroundColor->getPixel());

$borderColor = new ImagickColor($color);
Expand Down Expand Up @@ -686,7 +686,7 @@ public function text(

$textColor = new ImagickColor($color);

$draw = new ImagickDraw();
$draw = new ImagickDraw;
$draw->setFillColor($textColor->getPixel());
$draw->setFontSize($fontSize);
if ($fontPath) {
Expand Down Expand Up @@ -718,13 +718,13 @@ public function wrapText(string $text, int $fontSize, string $fontPath = '', int
foreach ($words as $word) {
$teststring = "{$wrapped} {$word}";

$draw = new ImagickDraw();
$draw = new ImagickDraw;
if ($fontPath) {
$draw->setFont($fontPath);
}
$draw->setFontSize($fontSize);

$metrics = (new Imagick())->queryFontMetrics($draw, $teststring);
$metrics = (new Imagick)->queryFontMetrics($draw, $teststring);

if ($metrics['textWidth'] > $width) {
$wrapped .= "\n".$word;
Expand Down
8 changes: 4 additions & 4 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Image implements ImageDriver

public function __construct(?string $pathToImage = null)
{
$this->imageDriver = new ImagickDriver();
$this->imageDriver = new ImagickDriver;

if ($pathToImage) {
$this->imageDriver->loadFile($pathToImage);
Expand Down Expand Up @@ -59,11 +59,11 @@ public static function useImageDriver(ImageDriverEnum|string $imageDriver): stat
}

$driver = match ($imageDriver) {
ImageDriverEnum::Gd => new GdDriver(),
ImageDriverEnum::Imagick => new ImagickDriver(),
ImageDriverEnum::Gd => new GdDriver,
ImageDriverEnum::Imagick => new ImagickDriver,
};

$image = new static();
$image = new static;
$image->imageDriver = $driver;

return $image;
Expand Down
2 changes: 1 addition & 1 deletion src/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Size
public function __construct(
public int $width,
public int $height,
public Point $pivot = new Point()
public Point $pivot = new Point
) {}

public function aspectRatio(): float
Expand Down
32 changes: 16 additions & 16 deletions tests/Colors/GdColorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,43 @@
use Spatie\Image\Exceptions\InvalidColor;

it('can create a new gd color object', function () {
$color = new GdColor();
$color = new GdColor;

validateGdColor($color, 255, 255, 255, 127);
});

it('can parse null', function () {
$color = (new GdColor())->parse(null);
$color = (new GdColor)->parse(null);

validateGdColor($color, 255, 255, 255, 127);
});

it('can parse an integer', function () {
$color = (new GdColor())->parse(850736919);
$color = (new GdColor)->parse(850736919);

validateGdColor($color, 181, 55, 23, 50);
});

it('can parse an array', function () {
$color = (new GdColor())->parse([181, 55, 23, 0.5]);
$color = (new GdColor)->parse([181, 55, 23, 0.5]);

validateGdColor($color, 181, 55, 23, 64);
});

it('can parse a hex string', function () {
$color = new GdColor();
$color = new GdColor;
$color->parse('#b53717');
validateGdColor($color, 181, 55, 23, 0);
});

it('can parse an rgba string', function () {
$color = (new GdColor())->parse('rgba(181, 55, 23, 1)');
$color = (new GdColor)->parse('rgba(181, 55, 23, 1)');

validateGdColor($color, 181, 55, 23, 0);
});

it('can initialize from an integer', function () {
$color = (new GdColor())->initFromInteger(0);
$color = (new GdColor)->initFromInteger(0);
validateGdColor($color, 0, 0, 0, 0);

$color->initFromInteger(2147483647);
Expand All @@ -57,7 +57,7 @@
});

it('can initialize from array', function () {
$color = (new GdColor())->initFromArray([0, 0, 0, 0]);
$color = (new GdColor)->initFromArray([0, 0, 0, 0]);
validateGdColor($color, 0, 0, 0, 127);

$color->initFromArray([0, 0, 0, 1]);
Expand Down Expand Up @@ -86,7 +86,7 @@
});

it('init can initialize from a hex string', function () {
$color = (new GdColor())->initFromString('#cccccc');
$color = (new GdColor)->initFromString('#cccccc');
validateGdColor($color, 204, 204, 204, 0);

$color->initFromString('#b53717');
Expand All @@ -106,7 +106,7 @@
});

it('can initialize from an rgb string', function () {
$color = (new GdColor())->initFromString('rgb(1, 14, 144)');
$color = (new GdColor)->initFromString('rgb(1, 14, 144)');
validateGdColor($color, 1, 14, 144, 0);

$color->initFromString('rgb (255, 255, 255)');
Expand All @@ -129,7 +129,7 @@
});

it('can initialize from rgb value', function () {
$color = (new GdColor())->initFromRgb(0, 0, 0);
$color = (new GdColor)->initFromRgb(0, 0, 0);
validateGdColor($color, 0, 0, 0, 0);

$color->initFromRgb(255, 255, 255);
Expand All @@ -140,7 +140,7 @@
});

it('can initialize from rgba values', function () {
$color = (new GdColor())->initFromRgba(0, 0, 0, 1);
$color = (new GdColor)->initFromRgba(0, 0, 0, 1);
validateGdColor($color, 0, 0, 0, 0);

$color->initFromRgba(255, 255, 255, 1);
Expand All @@ -157,7 +157,7 @@
});

it('can get the int value of a color', function () {
$color = new GdColor();
$color = new GdColor;
expect($color->getInt())->toEqual(2147483647);

$color = new GdColor([255, 255, 255]);
Expand All @@ -177,7 +177,7 @@
});

it('can get the hex value from a color', function () {
$color = new GdColor();
$color = new GdColor;
expect($color->getHex())->toEqual('ffffff');

$color = new GdColor([255, 255, 255, 1]);
Expand All @@ -191,7 +191,7 @@
});

it('can convert the color to an array', function () {
$color = new GdColor();
$color = new GdColor;
$i = $color->getArray();

expect([255, 255, 255, 0])->toEqual($i);
Expand All @@ -213,7 +213,7 @@
});

it('can get the rgba values', function () {
$color = (new GdColor());
$color = (new GdColor);
expect($color->getRgba())->toEqual('rgba(255, 255, 255, 0.00)');

$color = new GdColor([255, 255, 255, 1]);
Expand Down
26 changes: 13 additions & 13 deletions tests/Colors/ImagickColorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@
use Spatie\Image\Exceptions\InvalidColor;

it('can create an imagick color', function () {
$color = new ImagickColor();
$color = new ImagickColor;
validateImagickColor($color, 255, 255, 255, 0);
});

it('can parse null', function () {
$color = (new ImagickColor())->parse(null);
$color = (new ImagickColor)->parse(null);
validateImagickColor($color, 255, 255, 255, 0);
});

it('can parse an integer', function () {
$color = (new ImagickColor())->parse(16777215);
$color = (new ImagickColor)->parse(16777215);
validateImagickColor($color, 255, 255, 255, 0);

$color = (new ImagickColor())->parse(4294967295);
$color = (new ImagickColor)->parse(4294967295);
validateImagickColor($color, 255, 255, 255, 1);
});

it('can parse an array', function () {
$color = (new ImagickColor())->parse([181, 55, 23, 0.5]);
$color = (new ImagickColor)->parse([181, 55, 23, 0.5]);
validateImagickColor($color, 181, 55, 23, 0.5);
});

it('can parse a hex string', function () {
$color = (new ImagickColor())->parse('#b53717');
$color = (new ImagickColor)->parse('#b53717');
validateImagickColor($color, 181, 55, 23, 1);
});

it('can parse an rgba string', function () {
$color = (new ImagickColor())->parse('rgba(181, 55, 23, 1)');
$color = (new ImagickColor)->parse('rgba(181, 55, 23, 1)');
validateImagickColor($color, 181, 55, 23, 1);
});

it('can init from an integer', function (int $int, int $red, int $green, int $blue, float $alpha) {
$color = (new ImagickColor())->initFromInteger($int);
$color = (new ImagickColor)->initFromInteger($int);
validateImagickColor($color, $red, $green, $blue, $alpha);
})->with([
[0, 0, 0, 0, 0],
Expand All @@ -48,7 +48,7 @@
]);

it('can init from an array', function (array $input, int $red, int $green, int $blue, float $alpha) {
$color = (new ImagickColor())->initFromArray($input);
$color = (new ImagickColor)->initFromArray($input);
validateImagickColor($color, $red, $green, $blue, $alpha);
})->with([
[[0, 0, 0, 0], 0, 0, 0, 0],
Expand All @@ -64,7 +64,7 @@
]);

it('can init from a hex string', function (string $hexColor, int $red, int $green, int $blue, float $alpha) {
$color = (new ImagickColor())->initFromString($hexColor);
$color = (new ImagickColor)->initFromString($hexColor);
validateImagickColor($color, $red, $green, $blue, $alpha);
})->with([
['#cccccc', 204, 204, 204, 1],
Expand All @@ -76,7 +76,7 @@
]);

it('can init from an rgb string', function (string $rgbString, int $red, int $green, int $blue, float $alpha) {
$color = (new ImagickColor())->initFromString($rgbString);
$color = (new ImagickColor)->initFromString($rgbString);
validateImagickColor($color, $red, $green, $blue, $alpha);
})->with([
['rgb(1, 14, 144)', 1, 14, 144, 1],
Expand All @@ -89,7 +89,7 @@
]);

it('can init from rgb values', function (array $inputValues, array $expectedValues) {
$color = (new ImagickColor())->initFromRgb(...$inputValues);
$color = (new ImagickColor)->initFromRgb(...$inputValues);
validateImagickColor($color, ...$expectedValues);
})->with([
[[0, 0, 0], [0, 0, 0, 1]],
Expand All @@ -98,7 +98,7 @@
]);

it('can init from an rgba value', function (array $inputValues, array $expectedValues) {
$color = (new ImagickColor())->initFromRgba(...$inputValues);
$color = (new ImagickColor)->initFromRgba(...$inputValues);
validateImagickColor($color, ...$expectedValues);
})->with([
[[0, 0, 0, 1], [0, 0, 0, 1]],
Expand Down

0 comments on commit 9c3ec31

Please sign in to comment.