Skip to content

Commit

Permalink
Merge pull request #202 from TypiCMS/master
Browse files Browse the repository at this point in the history
Laravel 9 / Flysystem 3 version of Croppa with passing tests.
  • Loading branch information
weotch authored Apr 18, 2022
2 parents ccec1bf + ba4c9d7 commit 3b92985
Show file tree
Hide file tree
Showing 28 changed files with 1,177 additions and 947 deletions.
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
language: php

php:
- 5.5
- 5.6
- 7.0
- 7.1
- 8.0
- 8.1

before_script:
- composer install --dev
- yarn add mocha
- composer install --dev
- yarn add mocha

script:
- phpunit
- yarn mocha public/js/test
- phpunit
- yarn mocha public/js/test
92 changes: 46 additions & 46 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
{
"name": "bkwld/croppa",
"description": "Image thumbnail creation through specially formatted URLs for Laravel",
"authors": [
{
"name": "Robert Reinhard"
}
],
"license": "MIT",
"require": {
"php": "^7.2.5|^8.0",
"illuminate/console": "4 - 8",
"illuminate/support": "4 - 8",
"illuminate/routing": "4 - 8",
"league/flysystem": "~1.0",
"symfony/http-foundation": "2 - 5",
"symfony/http-kernel": "2 - 5",
"weotch/phpthumb": "^1.0.5",
"ext-gd": "*"
},
"require-dev": {
"phpunit/phpunit": "4 - 5",
"mockery/mockery": "~0.9"
},
"suggest": {
"ext-exif": "Required if you want to have Croppa auto-rotate images from devices like mobile phones based on exif meta data."
},
"conflict": {
"league/flysystem-cached-adapter": "<1.0.2"
},
"autoload": {
"psr-0": {
"Bkwld\\Croppa": "src/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"laravel": {
"providers": [
"Bkwld\\Croppa\\ServiceProvider"
],
"aliases": {
"Croppa": "Bkwld\\Croppa\\Facade"
}
}
}
"name": "bkwld/croppa",
"description": "Image thumbnail creation through specially formatted URLs for Laravel",
"authors": [
{
"name": "Robert Reinhard"
}
],
"license": "MIT",
"require": {
"php": "^8.0.2",
"illuminate/console": "^9.0",
"illuminate/support": "^9.0",
"illuminate/routing": "^9.0",
"league/flysystem": "^3.0",
"symfony/http-foundation": "^6.0",
"symfony/http-kernel": "^6.0",
"weotch/phpthumb": "^1.0.5",
"ext-gd": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.5.10",
"mockery/mockery": "^1.4.4"
},
"suggest": {
"ext-exif": "Required if you want to have Croppa auto-rotate images from devices like mobile phones based on exif meta data."
},
"conflict": {
"league/flysystem-cached-adapter": "<1.0.2"
},
"autoload": {
"psr-0": {
"Bkwld\\Croppa": "src/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"laravel": {
"providers": [
"Bkwld\\Croppa\\ServiceProvider"
],
"aliases": {
"Croppa": "Bkwld\\Croppa\\Facade"
}
}
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {},
"devDependencies": {
"mocha": "^3.5.3"
}
"dependencies": {},
"devDependencies": {
"mocha": "^3.5.3"
}
}
10 changes: 2 additions & 8 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
Expand Down
41 changes: 20 additions & 21 deletions src/Bkwld/Croppa/Commands/Purge.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?php namespace Bkwld\Croppa\Commands;
<?php

namespace Bkwld\Croppa\Commands;

// Deps
use Bkwld\Croppa\Storage;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;

/**
* Delete ALL crops from the crops_dir
* Delete ALL crops from the crops_dir.
*/
class Purge extends Command {

class Purge extends Command
{
/**
* The console command name.
*
Expand All @@ -30,46 +32,43 @@ class Purge extends Command {
protected $storage;

/**
* Dependency inject
*
* @param Storage $storage
* Dependency inject.
*/
public function __construct(Storage $storage) {
public function __construct(Storage $storage)
{
parent::__construct();
$this->storage = $storage;
}

/**
* Execute the console command
*
* @return void
* Execute the console command.
*/
public function handle() {
public function handle()
{
$dry = $this->input->getOption('dry-run');
foreach($this->storage->deleteAllCrops($this->input->getOption('filter'), $dry) as $path) {
$this->info(sprintf('%s %s', $path, $dry ? 'not deleted' : 'deleted' ));
foreach ($this->storage->deleteAllCrops($this->input->getOption('filter'), $dry) as $path) {
$this->info(sprintf('%s %s', $path, $dry ? 'not deleted' : 'deleted'));
}
}

/**
* Backwards compatability with Laravel 4
*
* @return void
* Backwards compatability with Laravel 4.
*/
public function fire() {
public function fire()
{
$this->handle();
}

/**
* Get the console command options
* Get the console command options.
*
* @return array;
*/
protected function getOptions() {
protected function getOptions()
{
return [
['filter', null, InputOption::VALUE_REQUIRED, 'A regex pattern that whitelists matching crop paths', null],
['dry-run', null, InputOption::VALUE_NONE, 'Only return the crops that would be deleted'],
];
}

}
8 changes: 6 additions & 2 deletions src/Bkwld/Croppa/Exception.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<?php namespace Bkwld\Croppa;
<?php

class Exception extends \Exception { }
namespace Bkwld\Croppa;

class Exception extends \Exception
{
}
6 changes: 4 additions & 2 deletions src/Bkwld/Croppa/Facade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php namespace Bkwld\Croppa;
<?php

namespace Bkwld\Croppa;

class Facade extends \Illuminate\Support\Facades\Facade
{
protected static function getFacadeAccessor()
protected static function getFacadeAccessor()
{
return 'Bkwld\Croppa\Helpers';
}
Expand Down
4 changes: 0 additions & 4 deletions src/Bkwld/Croppa/Filters/BlackWhite.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@

class BlackWhite implements FilterInterface
{

/**
* Applies filter to given thumbnail object.
*
* @param \GdThumb $thumb
*
* @return \Intervention\Image\Image
*/
public function applyFilter(GdThumb $thumb)
{
return $thumb->imageFilter(IMG_FILTER_GRAYSCALE);
}

}
4 changes: 0 additions & 4 deletions src/Bkwld/Croppa/Filters/Blur.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@

class Blur implements FilterInterface
{

/**
* Applies filter to given thumbnail object.
*
* @param \GdThumb $thumb
*
* @return \Intervention\Image\Image
*/
public function applyFilter(GdThumb $thumb)
{
return $thumb->imageFilter(IMG_FILTER_GAUSSIAN_BLUR);
}

}
5 changes: 1 addition & 4 deletions src/Bkwld/Croppa/Filters/Darkgray.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@

class Darkgray implements FilterInterface
{

/**
* Applies filter to given thumbnail object.
*
* @param \GdThumb $thumb
*
* @return \Intervention\Image\Image
*/
public function applyFilter(GdThumb $thumb)
{
$thumb->imageFilter(IMG_FILTER_GRAYSCALE);
$thumb->imageFilter(IMG_FILTER_COLORIZE, -80, -80, -80);

return $thumb;
}

}
2 changes: 0 additions & 2 deletions src/Bkwld/Croppa/Filters/FilterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
interface FilterInterface
{
/**
* @param \GdThumb $thumb
*
* @return \GdThumb $thumb
*/
public function applyFilter(GdThumb $thumb);
Expand Down
3 changes: 0 additions & 3 deletions src/Bkwld/Croppa/Filters/Negative.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class Negative implements FilterInterface
/**
* Applies filter to given thumbnail object.
*
* @param \GdThumb $thumb
*
* @return \Intervention\Image\Image
*/
public function applyFilter(GdThumb $thumb)
Expand All @@ -20,5 +18,4 @@ public function applyFilter(GdThumb $thumb)

return $thumb;
}

}
4 changes: 0 additions & 4 deletions src/Bkwld/Croppa/Filters/OrangeWarhol.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class OrangeWarhol implements FilterInterface
/**
* Applies filter to given thumbnail object.
*
* @param \GdThumb $thumb
*
* @return \Intervention\Image\Image
*/
public function applyFilter(GdThumb $thumb)
Expand All @@ -21,6 +19,4 @@ public function applyFilter(GdThumb $thumb)

return $thumb;
}


}
3 changes: 0 additions & 3 deletions src/Bkwld/Croppa/Filters/TurquoiseWarhol.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class TurquoiseWarhol implements FilterInterface
/**
* Applies filter to given thumbnail object.
*
* @param \GdThumb $thumb
*
* @return \Intervention\Image\Image
*/
public function applyFilter(GdThumb $thumb)
Expand All @@ -21,5 +19,4 @@ public function applyFilter(GdThumb $thumb)

return $thumb;
}

}
Loading

0 comments on commit 3b92985

Please sign in to comment.