Skip to content

Commit

Permalink
Merge a8f08df into ae5e267
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Nov 24, 2020
2 parents ae5e267 + a8f08df commit a4cd5c2
Show file tree
Hide file tree
Showing 44 changed files with 720 additions and 490 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
@@ -0,0 +1,14 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.yml]
indent_size = 2
32 changes: 24 additions & 8 deletions .travis.yml
Expand Up @@ -9,19 +9,35 @@ php:
- 7.4
- 8.0snapshot

env:
global:
- DEFAULT=1

matrix:
fast_finish: true

include:
- php: 7.4
env: PHPCS=1 DEFAULT=0
- php: 7.2
env: STATIC_ANALYSIS=1 DEFAULT=0

cache:
directories:
- $HOME/.composer/cache

before_install:
- travis_retry composer self-update

install:
- travis_retry composer update --no-interaction --prefer-source
- composer update --no-interaction
- if [[ $STATIC_ANALYSIS == 1 ]]; then composer require --dev psalm/phar:^3.13; fi

script:
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
- if [[ $DEFAULT == 1 ]]; then vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover; fi
- if [[ $PHPCS == 1 ]]; then vendor/bin/phpcs -p --standard=PSR12 ./src ./tests; fi
- if [[ $STATIC_ANALYSIS == 1 ]]; then vendor/bin/psalm.phar; fi

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
after_success:
- |
if [[ $DEFAULT == 1 ]]; then
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
fi
7 changes: 4 additions & 3 deletions composer.json
Expand Up @@ -21,15 +21,16 @@
}
],
"require": {
"intervention/image": "^2.4",
"league/flysystem": "^1.0",
"php": "^7.2|^8.0",
"intervention/image": "^2.4",
"league/flysystem": "^2.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"mockery/mockery": "^1.3.3",
"phpunit/phpunit": "^8.5|^9.0",
"phpunit/php-token-stream": "^3.1|^4.0"
"phpunit/php-token-stream": "^3.1|^4.0",
"squizlabs/php_codesniffer": "^3.5"
},
"autoload": {
"psr-4": {
Expand Down
15 changes: 15 additions & 0 deletions psalm.xml
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
14 changes: 9 additions & 5 deletions src/Api/Api.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace League\Glide\Api;

use Intervention\Image\ImageManager;
Expand Down Expand Up @@ -34,8 +36,9 @@ public function __construct(ImageManager $imageManager, array $manipulators)
/**
* Set the image manager.
* @param ImageManager $imageManager Intervention image manager.
* @return void
*/
public function setImageManager(ImageManager $imageManager)
public function setImageManager(ImageManager $imageManager): void
{
$this->imageManager = $imageManager;
}
Expand All @@ -44,16 +47,17 @@ public function setImageManager(ImageManager $imageManager)
* Get the image manager.
* @return ImageManager Intervention image manager.
*/
public function getImageManager()
public function getImageManager(): ImageManager
{
return $this->imageManager;
}

/**
* Set the manipulators.
* @param array $manipulators Collection of manipulators.
* @return void
*/
public function setManipulators(array $manipulators)
public function setManipulators(array $manipulators): void
{
foreach ($manipulators as $manipulator) {
if (!($manipulator instanceof ManipulatorInterface)) {
Expand All @@ -68,7 +72,7 @@ public function setManipulators(array $manipulators)
* Get the manipulators.
* @return array Collection of manipulators.
*/
public function getManipulators()
public function getManipulators(): array
{
return $this->manipulators;
}
Expand All @@ -79,7 +83,7 @@ public function getManipulators()
* @param array $params The manipulation params.
* @return string Manipulated image binary data.
*/
public function run($source, array $params)
public function run(string $source, array $params): string
{
$image = $this->imageManager->make($source);

Expand Down
4 changes: 3 additions & 1 deletion src/Api/ApiInterface.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace League\Glide\Api;

interface ApiInterface
Expand All @@ -10,5 +12,5 @@ interface ApiInterface
* @param array $params The manipulation params.
* @return string Manipulated image binary data.
*/
public function run($source, array $params);
public function run(string $source, array $params): string;
}
2 changes: 2 additions & 0 deletions src/Filesystem/FileNotFoundException.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace League\Glide\Filesystem;

use Exception;
Expand Down
2 changes: 2 additions & 0 deletions src/Filesystem/FilesystemException.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace League\Glide\Filesystem;

use Exception;
Expand Down
4 changes: 3 additions & 1 deletion src/Manipulators/Background.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace League\Glide\Manipulators;

use Intervention\Image\Image;
Expand All @@ -15,7 +17,7 @@ class Background extends BaseManipulator
* @param Image $image The source image.
* @return Image The manipulated image.
*/
public function run(Image $image)
public function run(Image $image): Image
{
if (is_null($this->bg)) {
return $image;
Expand Down
5 changes: 4 additions & 1 deletion src/Manipulators/BaseManipulator.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace League\Glide\Manipulators;

use Intervention\Image\Image;
Expand All @@ -15,6 +17,7 @@ abstract class BaseManipulator implements ManipulatorInterface
/**
* Set the manipulation params.
* @param array $params The manipulation params.
* @return $this
*/
public function setParams(array $params)
{
Expand All @@ -39,5 +42,5 @@ public function __get($name)
* Perform the image manipulation.
* @return Image The manipulated image.
*/
abstract public function run(Image $image);
abstract public function run(Image $image): Image;
}
12 changes: 7 additions & 5 deletions src/Manipulators/Blur.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace League\Glide\Manipulators;

use Intervention\Image\Image;
Expand All @@ -14,7 +16,7 @@ class Blur extends BaseManipulator
* @param Image $image The source image.
* @return Image The manipulated image.
*/
public function run(Image $image)
public function run(Image $image): Image
{
$blur = $this->getBlur();

Expand All @@ -27,16 +29,16 @@ public function run(Image $image)

/**
* Resolve blur amount.
* @return string The resolved blur amount.
* @return int|null The resolved blur amount.
*/
public function getBlur()
public function getBlur(): ?int
{
if (!is_numeric($this->blur)) {
return;
return null;
}

if ($this->blur < 0 or $this->blur > 100) {
return;
return null;
}

return (int) $this->blur;
Expand Down

0 comments on commit a4cd5c2

Please sign in to comment.