Skip to content

Commit 6207d52

Browse files
committed
Applied suggestions by CodeRabbit
1 parent a79b3ed commit 6207d52

5 files changed

Lines changed: 4 additions & 17 deletions

File tree

src/Modifier/Codec/Codec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function modifiersToPath(string|array $value): string
2929
{
3030
if (!is_array($value)) {
3131
throw new InvalidArgumentException(
32-
message: 'Can not decode value of type string, the value must be array<string, string|numeric|bool>.',
32+
message: 'Can not transform value of type string, the value must be array<string, string|numeric|bool>.',
3333
);
3434
}
3535

src/Responsive/Descriptor/DescriptorInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function validateModifierValue(
2323
): mixed;
2424

2525
/**
26-
* @return array<string, string|numeric|bool>
26+
* @param string|numeric|bool $value
2727
*
2828
* @return array<string, string|numeric|bool>
2929
* @throws InvalidArgumentException

src/Responsive/Descriptor/WDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function validateModifierValue(
6464
mixed $default,
6565
): int {
6666
if (true === $value) {
67-
if (!is_numeric($default)) {
67+
if (!is_numeric($default) && [] !== $this->widths) {
6868
return $this->widths[0];
6969
}
7070

src/Responsive/Descriptor/XDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function validateModifierValue(
4444
mixed $default,
4545
): float {
4646
if (true === $value) {
47-
if (!is_numeric($default)) {
47+
if (!is_numeric($default) && [] !== $this->pixelDensities) {
4848
return $this->pixelDensities[0];
4949
}
5050

tests/Modifier/Codec/CodecTest.phpt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use SixtyEightPublishers\ImageStorage\Modifier\ModifierInterface;
1515
use SixtyEightPublishers\ImageStorage\Modifier\ParsableModifierInterface;
1616
use Tester\Assert;
1717
use Tester\TestCase;
18-
use TypeError;
1918
use function assert;
2019

2120
require __DIR__ . '/../../bootstrap.php';
@@ -78,18 +77,6 @@ final class CodecTest extends TestCase
7877
]));
7978
}
8079

81-
public function testExceptionShouldBeThrownIfNonStringValueIsDecoded(): void
82-
{
83-
$config = Mockery::mock(ConfigInterface::class);
84-
$modifierCollection = Mockery::mock(ModifierCollectionInterface::class);
85-
$codec = new Codec($config, $modifierCollection);
86-
87-
Assert::exception(
88-
static fn () => $codec->pathToModifiers([]),
89-
TypeError::class,
90-
);
91-
}
92-
9380
public function testExceptionShouldBeThrownIfEmptyStringValueIsDecoded(): void
9481
{
9582
$config = Mockery::mock(ConfigInterface::class);

0 commit comments

Comments
 (0)