Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v5 - Support Laravel ^11, upgrade to Intervention Image v3 #26

Merged
merged 7 commits into from
May 23, 2024
Merged
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
27 changes: 3 additions & 24 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,9 @@ jobs:
strategy:
max-parallel: 10
matrix:
laravel-version: ['^6.0', '^7.0', '^8.0', '^9.0', '^10.0']
laravel-version: ['^11.1']
preference: ['stable']
php-version: ['7.4', '8.0', '8.1', '8.2']
exclude:
- laravel-version: ^6.0
php-version: 8.0
- laravel-version: ^6.0
php-version: 8.1
- laravel-version: ^6.0
php-version: 8.2
- laravel-version: ^7.0
php-version: 8.0
- laravel-version: ^7.0
php-version: 8.1
- laravel-version: ^7.0
php-version: 8.2
- laravel-version: ^9.0
php-version: 7.4
- laravel-version: ^9.0
php-version: 8.2
- laravel-version: ^10.0
php-version: 7.4
- laravel-version: ^10.0
php-version: 8.0
php-version: ['8.2', '8.3']
name: Laravel ${{ matrix.laravel-version }} (${{ matrix.preference }}) on PHP ${{ matrix.php-version }}
steps:
- name: Checkout
Expand All @@ -56,7 +35,7 @@ jobs:
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }} #required
file: ./coverage.xml #optional
file: ./build/coverage.xml #optional
flags: unittests #optional
name: codecov-umbrella #optional
fail_ci_if_error: true #optional (default = false)
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"illuminate/support": "6 - 10",
"intervention/image": "^2.4",
"intervention/imagecache": "^2.0",
"reliqarts/laravel-common": "5.4 - 6",
"php": "^8.2",
"illuminate/support": "^11.1",
"intervention/image": "^3.6",
"reliqarts/laravel-common": "^8.0",
"ext-json": "*",
"ext-fileinfo": "*",
"anhskohbo/no-captcha": "@dev"
},
"require-dev": {
"orchestra/testbench": "4 - 8",
"phpro/grumphp": "^1.0",
"laravel/pint": "^1.15",
"orchestra/testbench": "^9.0",
"phpro/grumphp": "^2.5",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.3",
"symplify/easy-coding-standard": ">=8.2"
"phpunit/phpunit": "^11.0",
"yieldstudio/grumphp-laravel-pint": "^1.0"
},
"autoload": {
"psr-4": {
Expand All @@ -46,8 +46,8 @@
},
"scripts": {
"test": "phpunit",
"test:ci": "phpunit --verbose --colors=auto --coverage-clover=coverage.xml",
"test:unit": "phpunit --testsuite=Unit --verbose --coverage-clover=coverage.xml"
"test:ci": "phpunit --colors=auto --coverage-clover=build/coverage.xml",
"test:unit": "phpunit --testsuite=Unit --verbose --coverage-clover=build/coverage.xml"
},
"config": {
"sort-packages": true,
Expand Down
4 changes: 2 additions & 2 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

// image encoding @see: http://image.intervention.io/api/encode
'encoding' => [
'format' => env('GUIDED_IMAGE_ENCODING_FORMAT', 'png'),
'mime_type' => env('GUIDED_IMAGE_ENCODING_MIME_TYPE', 'image/png'),
'quality' => env('GUIDED_IMAGE_ENCODING_QUALITY', 90),
],

Expand Down Expand Up @@ -92,5 +92,5 @@
'dispenser' => [
// whether raw image should be served as fallback if NotReadableException occurs
'raw_image_fallback_enabled' => env('GUIDED_IMAGE_DISPENSER_RAW_IMAGE_FALLBACK_ENABLED', false),
]
],
];
16 changes: 0 additions & 16 deletions ecs.php

This file was deleted.

15 changes: 6 additions & 9 deletions grumphp.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
grumphp:
extensions:
- YieldStudio\GrumPHPLaravelPint\ExtensionLoader
tasks:
ecs:
config: ~
level: ~
paths: [ ]
files_on_pre_commit: false
triggered_by: [ 'php' ]
clear-cache: false
no-progress-bar: true
laravel_pint:
config: pint.json
preset: laravel
phpunit:
config_file: ~
testsuite: Unit
testsuite: ~
group: [ ]
always_execute: false
21 changes: 10 additions & 11 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" beStrictAboutTestsThatDoNotTestAnything="true" bootstrap="tests/bootstrap.php" cacheResult="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" verbose="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory suffix=".php">src/Concerns</directory>
</exclude>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" beStrictAboutTestsThatDoNotTestAnything="true" bootstrap="tests/bootstrap.php" cacheResult="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<report>
<clover outputFile="build/coverage.xml"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
<testsuites>
<testsuite name="Tests">
<directory suffix=".php">tests</directory>
</testsuite>
<testsuite name="Integration">
<directory suffix="Test.php">tests/Feature</directory>
</testsuite>
Expand All @@ -32,4 +23,12 @@
<env name="GUIDED_IMAGE_MODEL" value="GuidedImage"/>
</php>
<logging/>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory suffix=".php">src/Concerns</directory>
</exclude>
</source>
</phpunit>
3 changes: 3 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"preset": "psr12"
}
44 changes: 7 additions & 37 deletions src/Concern/Guide.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Illuminate\Http\Request;
use ReliqArts\GuidedImage\Contract\GuidedImage;
use ReliqArts\GuidedImage\Contract\ImageDispenser;
use ReliqArts\GuidedImage\Demand\Dummy;
use ReliqArts\GuidedImage\Demand\Resize;
use ReliqArts\GuidedImage\Demand\Thumbnail;
use ReliqArts\GuidedImage\Result;
Expand All @@ -36,59 +35,30 @@ public function emptyCache(ImageDispenser $imageDispenser): JsonResponse
);
}

/**
* @param mixed $width
* @param mixed $height
* @param mixed $aspect
* @param mixed $upSize
*/
public function resized(
ImageDispenser $imageDispenser,
Request $request,
GuidedImage $guidedImage,
$width,
$height,
$aspect = true,
$upSize = false
mixed $width,
mixed $height,
mixed $aspect = true,
mixed $upSize = false
): Response {
$demand = new Resize($request, $guidedImage, $width, $height, $aspect, $upSize);

return $imageDispenser->getResizedImage($demand);
}

/**
* @param mixed $method
* @param mixed $width
* @param mixed $height
*/
public function thumb(
ImageDispenser $imageDispenser,
Request $request,
GuidedImage $guidedImage,
$method,
$width,
$height
mixed $method,
mixed $width,
mixed $height
): Response {
$demand = new Thumbnail($request, $guidedImage, $method, $width, $height);

return $imageDispenser->getImageThumbnail($demand);
}

/**
* @param mixed $width
* @param mixed $height
* @param mixed $color
* @param mixed $fill
*/
public function dummy(
ImageDispenser $imageDispenser,
$width,
$height,
$color = null,
$fill = null
): Response {
$demand = new Dummy($width, $height, $color, $fill);

return $imageDispenser->getDummyImage($demand);
}
}
8 changes: 3 additions & 5 deletions src/Contract/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ public function getRoutePrefix(): string;
/**
* Get image model for guided image routes.
*
* @param bool $lowered whether model should be returned in lowercase form
*
* @param bool $lowered whether model should be returned in lowercase form
* @return string model name
*/
public function getGuidedModelName(bool $lowered = false): string;

/**
* Get image model namespace for guided image routes.
*
* @param bool $lowered whether model should be returned in lowercase form
*
* @param bool $lowered whether model should be returned in lowercase form
* @return string model namespace
*/
public function getGuidedModelNamespace(bool $lowered = false): string;
Expand Down Expand Up @@ -73,7 +71,7 @@ public function getAdditionalHeaders(): array;

public function getCacheDirectory(): string;

public function getImageEncodingFormat(): string;
public function getImageEncodingMimeType(): string;

public function getImageEncodingQuality(): int;

Expand Down
7 changes: 1 addition & 6 deletions src/Contract/ImageDemand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,5 @@ public function getWidth(): ?int;

public function getHeight(): ?int;

public function returnObject(): bool;

/**
* @param mixed $value
*/
public function isValueConsideredNull($value): bool;
public function isValueConsideredNull(mixed $value): bool;
}
11 changes: 6 additions & 5 deletions src/Contract/ImageDispenser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,33 @@

namespace ReliqArts\GuidedImage\Contract;

use Intervention\Image\Image;
use Intervention\Image\Interfaces\ImageInterface;
use ReliqArts\GuidedImage\Demand\Dummy;
use ReliqArts\GuidedImage\Demand\Resize;
use ReliqArts\GuidedImage\Demand\Thumbnail;
use RuntimeException;
use Symfony\Component\HttpFoundation\Response;

interface ImageDispenser
{
/**
* @return Image|Response
* @return ImageInterface|Response
*/
public function getImageThumbnail(Thumbnail $demand);

/**
* Get a resized Guided Image.
*
* @return Image|Response
* @return ImageInterface|Response
*/
public function getResizedImage(Resize $demand);

/**
* Get dummy Guided Image.
*
* @return Image|Response
* @throws RuntimeException
*/
public function getDummyImage(Dummy $demand);
public function getDummyImage(Dummy $demand): ImageInterface;

public function emptyCache(): bool;
}
26 changes: 26 additions & 0 deletions src/Contract/ImageManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace ReliqArts\GuidedImage\Contract;

use Intervention\Image\Interfaces\DecoderInterface;
use Intervention\Image\Interfaces\ImageInterface;
use RuntimeException;

interface ImageManager
{
/**
* @throws RuntimeException
*
* @see \Intervention\Image\ImageManager::create()
*/
public function create(int $width, int $height): ImageInterface;

/**
* @throws RuntimeException
*
* @see \Intervention\Image\ImageManager::read()
*/
public function read(mixed $input, string|array|DecoderInterface $decoders = []): ImageInterface;
}
11 changes: 0 additions & 11 deletions src/Contract/Logger.php

This file was deleted.

Loading
Loading