Skip to content

Commit 21b0ff2

Browse files
committed
Add new processing options
1 parent 426e72f commit 21b0ff2

38 files changed

Lines changed: 256 additions & 183 deletions

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ jobs:
2424
run: |
2525
composer install --no-progress
2626
27+
- name: Run PHPStan
28+
run: |
29+
make phpstan
30+
2731
- name: Run tests
2832
run: |
2933
make test

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
phpstan:
2-
vendor/bin/phpstan analyse --level max src tests
2+
vendor/bin/phpstan analyse -c phpstan.neon
33

44
test: phpstan
55
vendor/bin/phpunit --verbose

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"require-dev": {
1111
"phpunit/phpunit": "^8.5.8|^9.3.3",
12-
"phpstan/phpstan": "^0.12"
12+
"phpstan/phpstan": "^2.1"
1313
},
1414
"autoload": {
1515
"psr-4": {

phpstan.neon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
ignoreErrors:
3+
- '#no value type specified in iterable type array#'
4+
level: 9
5+
paths:
6+
- src
7+
- tests

src/Options/AbstractOption.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ abstract public function data(): array;
4444
*/
4545
public function value(): string
4646
{
47-
$data = $this->data();
47+
$data = array_map('strval', $this->data());
4848

4949
array_unshift($data, $this->name());
5050

src/Options/AutoRotate.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@
66

77
final class AutoRotate extends AbstractOption
88
{
9-
private bool $rotate;
10-
11-
public function __construct(bool $rotate = true)
12-
{
13-
$this->rotate = $rotate;
14-
}
9+
public function __construct(
10+
private bool $rotate = true,
11+
) {}
1512

1613
/**
1714
* @inheritDoc

src/Options/Blur.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88

99
final class Blur extends AbstractOption
1010
{
11-
private float $sigma;
12-
13-
public function __construct(float $sigma)
11+
public function __construct(
12+
private float $sigma,
13+
)
1414
{
1515
if ($sigma < 0) {
1616
throw new InvalidArgumentException(sprintf('Invalid blur: %s', $sigma));
1717
}
18-
19-
$this->sigma = $sigma;
2018
}
2119

2220
/**

src/Options/CacheBuster.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@
88

99
final class CacheBuster extends AbstractOption
1010
{
11-
private string $value;
12-
13-
public function __construct(string $value)
14-
{
11+
public function __construct(
12+
private string $value,
13+
) {
1514
if (empty($value)) {
1615
throw new InvalidArgumentException('Cache buster cannot be empty');
1716
}
18-
19-
$this->value = $value;
2017
}
2118

2219
/**

src/Options/Crop.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ final class Crop extends AbstractOption
88
{
99
private Width $width;
1010
private Height $height;
11-
private ?Gravity $gravity = null;
11+
private ?Gravity $gravity;
1212

1313
public function __construct(int $width, int $height, Gravity|string|null $gravity = null)
1414
{

src/Options/Dpr.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@
88

99
final class Dpr extends AbstractOption
1010
{
11-
private int $dpr;
12-
13-
public function __construct(int $dpr)
14-
{
11+
public function __construct(
12+
private int $dpr,
13+
) {
1514
if ($dpr <= 0) {
1615
throw new InvalidArgumentException(sprintf('Invalid dpr: %s', $dpr));
1716
}
18-
19-
$this->dpr = $dpr;
2017
}
2118

2219
/**

0 commit comments

Comments
 (0)