-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
94 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the zenstruck/image package. | ||
* | ||
* (c) Kevin Bond <kevinbond@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Image\Transformer; | ||
|
||
use Spatie\Image\Image; | ||
|
||
/** | ||
* @author Kevin Bond <kevinbond@gmail.com> | ||
* | ||
* @internal | ||
* | ||
* @extends FileTransformer<Image> | ||
*/ | ||
final class SpatieImageTransformer extends FileTransformer | ||
{ | ||
protected function object(\SplFileInfo $image): object | ||
{ | ||
return Image::load($image); | ||
} | ||
|
||
protected static function expectedClass(): string | ||
{ | ||
return Image::class; | ||
} | ||
|
||
protected function save(object $object, array $options): void | ||
{ | ||
$object | ||
->format($options['format']) | ||
->save($options['output']) | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the zenstruck/image package. | ||
* | ||
* (c) Kevin Bond <kevinbond@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Image\Tests\Transformer; | ||
|
||
use Spatie\Image\Image; | ||
use Zenstruck\Image\Tests\TransformerTestCase; | ||
|
||
/** | ||
* @author Kevin Bond <kevinbond@gmail.com> | ||
*/ | ||
final class SpatieImageTransformerTest extends TransformerTestCase | ||
{ | ||
protected function invalidFilterCallback(): callable | ||
{ | ||
return fn(Image $i) => null; | ||
} | ||
|
||
protected function filterInvokable(): object | ||
{ | ||
return new class() { | ||
public function __invoke(Image $image): Image | ||
{ | ||
return $image->width(100); | ||
} | ||
}; | ||
} | ||
|
||
protected function filterCallback(): callable | ||
{ | ||
return fn(Image $i) => $i->width(100); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters