Skip to content

Commit

Permalink
phpstan fixes, code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Gappa committed Jun 13, 2022
1 parent d90c28f commit 186a198
Show file tree
Hide file tree
Showing 14 changed files with 12 additions and 35 deletions.
6 changes: 2 additions & 4 deletions src/Dimensions.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?php
declare(strict_types=1);

namespace Nelson\Resizer;

class Dimensions
{

public function __construct(
private int $width,
private int $height
)
{
) {
}


Expand All @@ -29,5 +28,4 @@ public function getRatio(): float
{
return $this->width / $this->height;
}

}
1 change: 0 additions & 1 deletion src/Exceptions/CouldNotParseResizerParamsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@

final class CouldNotParseResizerParamsException extends Exception
{

}
1 change: 0 additions & 1 deletion src/Exceptions/ImageNotFoundOrReadableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@

final class ImageNotFoundOrReadableException extends Exception
{

}
1 change: 0 additions & 1 deletion src/Exceptions/IncompatibleResizerParamsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@

final class IncompatibleResizerParamsException extends Exception
{

}
1 change: 0 additions & 1 deletion src/Exceptions/SecurityException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@

final class SecurityException extends Exception
{

}
3 changes: 0 additions & 3 deletions src/Geometry.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@

use Imagine\Image\Point;
use Nelson\Resizer\Exceptions\IncompatibleResizerParamsException;
use Nette\InvalidArgumentException;
use Nette\SmartObject;

final class Geometry
{
use SmartObject;


private ResizerParams $resizerParams;


Expand Down Expand Up @@ -142,5 +140,4 @@ public function getCropPoint(Dimensions $source): Point

return new Point((int) $x, (int) $y);
}

}
4 changes: 2 additions & 2 deletions src/Latte/RlinkNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public static function create(Tag $tag): ?static

public function print(PrintContext $context): string
{
return $context->format(''
return $context->format(
''
. '$lg = $this->global->uiPresenter ?? $this->global->uiControl;'
. 'echo %modify('
. '$lg->link(Nelson\Resizer\Latte\RlinkNode::getLink($lg), %node)) %line;',
$this->modifier,
$this->args,
$this->position,
);

}


Expand Down
1 change: 0 additions & 1 deletion src/Presenters/ResizePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Nette\Http\Context;
use Nette\Http\IRequest;
use Nette\Http\IResponse;
use Nette\Http\Response;
use Nette\Utils\DateTime;

final class ResizePresenter extends Presenter
Expand Down
2 changes: 0 additions & 2 deletions src/Resizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace Nelson\Resizer;

use Exception;
use Imagine\Exception\RuntimeException;
use Imagine\Image\AbstractImagine;
use Imagine\Image\Box;
Expand All @@ -18,7 +17,6 @@ final class Resizer implements IResizer
{
use SmartObject;

/** @var string[] */
private const SUPPORTED_FORMATS = [
'jpeg',
'jpg',
Expand Down
18 changes: 7 additions & 11 deletions src/ResizerParams.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
declare(strict_types=1);

namespace Nelson\Resizer;

class ResizerParams
{

public function __construct(
private bool $ifresize,
private ?string $horizontal,
Expand All @@ -14,8 +14,7 @@ public function __construct(
private ?string $verticalMargin,
private ?int $width,
private ?int $height
)
{
) {
}


Expand Down Expand Up @@ -63,7 +62,7 @@ public function getWidth(): ?int

public function hasWidth(): bool
{
return null !== $this->width;
return $this->width !== null;
}


Expand All @@ -75,25 +74,25 @@ public function getHeight(): ?int

public function hasHeight(): bool
{
return null !== $this->height;
return $this->height !== null;
}


public function hasBothDimensions(): bool
{
return ($this->width !== null && $this->height !== null);
return $this->width !== null && $this->height !== null;
}


public function hasOneDimension(): bool
{
return ($this->width !== null || $this->height !== null);
return $this->width !== null || $this->height !== null;
}


public function hasNoDimensions(): bool
{
return ($this->width === null && $this->height === null);
return $this->width === null && $this->height === null;
}


Expand All @@ -105,7 +104,4 @@ public function isCrop(): bool
($this->vertical !== null && strlen($this->vertical) === 1)
;
}



}
3 changes: 0 additions & 3 deletions src/ResizerParamsParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace Nelson\Resizer;

use Exception;
use Nelson\Resizer\Exceptions\CouldNotParseResizerParamsException;
use Nette\SmartObject;

Expand Down Expand Up @@ -72,6 +71,4 @@ private function parseNumericValueToIntOrNull(string $value): ?int

return null;
}


}
1 change: 0 additions & 1 deletion tests/GeometryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

class GeometryTest extends TestCase
{

private static Dimensions $sourceDimensions;


Expand Down
1 change: 0 additions & 1 deletion tests/ResizerParamsParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

class ResizerParamsParserTest extends TestCase
{

public function testEmpty(): void
{
$expected = new ResizerParams(
Expand Down
4 changes: 1 addition & 3 deletions tests/ResizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

class ResizerTest extends TestCase
{

private static Resizer $resizer;
private static string $image;
private static ResizerConfig $config;
Expand All @@ -23,7 +22,7 @@ public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();

static::$config = new ResizerConfig();
static::$config = new ResizerConfig;
static::$config->tempDir = __DIR__ . '/../temp';
static::$config->wwwDir = __DIR__ . '/../tests';
static::$config->qualityJpeg = 65;
Expand Down Expand Up @@ -88,5 +87,4 @@ public static function tearDownAfterClass(): void
parent::tearDownAfterClass();
FileSystem::delete(static::$config->tempDir . static::$config->cache);
}

}

0 comments on commit 186a198

Please sign in to comment.