Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,31 @@ parameters:
count: 1
path: src/ImageStorage.php

-
message: "#^Negated boolean expression is always false\\.$#"
count: 1
path: src/ImageStorage.php

-
message: "#^Offset 1 does not exist on array\\{0\\?\\: string, 1\\?\\: ''\\|numeric\\-string, 2\\?\\: ''\\|numeric\\-string, 3\\?\\: string, 4\\?\\: ''\\|numeric\\-string, 5\\?\\: ''\\|numeric\\-string, 6\\?\\: ''\\|numeric\\-string, 7\\?\\: numeric\\-string\\}\\.$#"
count: 1
path: src/ImageStorage.php

-
message: "#^Offset 1 does not exist on array\\{0\\?\\: string, 1\\?\\: string, 2\\: non\\-falsy\\-string\\}\\.$#"
count: 1
path: src/ImageStorage.php

-
message: "#^Offset 2 does not exist on array\\{0\\?\\: string, 1\\?\\: ''\\|numeric\\-string, 2\\?\\: ''\\|numeric\\-string, 3\\?\\: string, 4\\?\\: ''\\|numeric\\-string, 5\\?\\: ''\\|numeric\\-string, 6\\?\\: ''\\|numeric\\-string, 7\\?\\: numeric\\-string\\}\\.$#"
count: 1
path: src/ImageStorage.php

-
message: "#^Offset 2 does not exist on array\\{0\\?\\: string, 1\\?\\: string, 2\\?\\: non\\-falsy\\-string\\}\\.$#"
count: 1
path: src/ImageStorage.php

-
message: "#^Only booleans are allowed in &&, int given on the right side\\.$#"
count: 1
Expand Down
5 changes: 5 additions & 0 deletions src/ImageNameScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ public function setQuality(int $quality): void
$this->quality = $quality;
}

public function setExtension(string $extension): void
{
$this->extension = $extension;
}

public function getIdentifier(): string
{
$identifier = implode('/', [$this->namespace, $this->prefix, $this->name]);
Expand Down
1 change: 1 addition & 0 deletions src/ImageStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public function fromIdentifier(mixed $args): Image
$script->setCrop($crop);
$script->setFlag($flag);
$script->setQuality($quality);
$script->setExtension($args[4] ?? $script->extension);

$identifier = $script->getIdentifier();
$data_file = implode('/', [$this->data_path, $identifier]);
Expand Down
5 changes: 3 additions & 2 deletions tests/Cases/ImageNameScriptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ public function testFromIdentifier(): void
$s->setQuality(2);
$s->setSize([2, 2]);
$s->setFlag('exact');
$s->setExtension('png');

Assert::same($s->getIdentifier(), 'images/49/kitty.2x2.exact.q2.jpg');
Assert::same($s->toQuery(), 'images/49/2x2.exact.q2/kitty.jpg?_image_storage');
Assert::same($s->getIdentifier(), 'images/49/kitty.2x2.exact.q2.png');
Assert::same($s->toQuery(), 'images/49/2x2.exact.q2/kitty.png?_image_storage');
}

}
Expand Down
2 changes: 1 addition & 1 deletion tests/Cases/ImageStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function testUpload(): void
$upload = new FileUpload([
'name' => 'upload.jpg',
'type' => 'image/jpg',
'size' => '20',
'size' => 20,
'tmp_name' => $tempImagePath,
'error' => 0,
]);
Expand Down