Skip to content

Commit

Permalink
Merge b0801f2 into 9a5023c
Browse files Browse the repository at this point in the history
  • Loading branch information
antalaron committed Dec 25, 2019
2 parents 9a5023c + b0801f2 commit abcb3d0
Show file tree
Hide file tree
Showing 47 changed files with 192 additions and 910 deletions.
27 changes: 9 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,32 @@ sudo: false
dist: trusty

php:
- 5.5
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
- nightly

env:
- SYMFONY_VERSION="2.7.*"
- SYMFONY_VERSION="2.8.*"
- SYMFONY_VERSION="3.4.*"
- SYMFONY_VERSION="4.0.*"
- SYMFONY_VERSION="4.4.*"
- SYMFONY_VERSION="5.0.*"

matrix:
fast_finish: true
exclude:
- php: 5.5
env: SYMFONY_VERSION="4.0.*"
- php: 5.5
env: SYMFONY_VERSION="dev-master"
- php: 7.0
env: SYMFONY_VERSION="4.0.*"
- php: 7.0
env: SYMFONY_VERSION="dev-master"
- php: 7.1
env: SYMFONY_VERSION="5.0.*"
allow_failures:
- php: nightly

before_script:
- composer require symfony/symfony:${SYMFONY_VERSION} --prefer-dist --no-interaction --no-progress
- mkdir -p build/logs
- if [ "${TRAVIS_PHP_VERSION}" == '7.1' ] && [ "${SYMFONY_VERSION}" == '3.4.*' ]; then composer require doctrine/orm doctrine/doctrine-bundle doctrine/mongodb-odm-bundle alcaeus/mongo-php-adapter --ignore-platform-reqs --no-interaction --no-progress; fi;

script:
- if [ "${TRAVIS_PHP_VERSION}" != '7.1' ] || [ "${SYMFONY_VERSION}" != '3.4.*' ]; then vendor/bin/phpunit -v; fi;
- if [ "${TRAVIS_PHP_VERSION}" == '7.1' ] && [ "${SYMFONY_VERSION}" == '3.4.*' ]; then vendor/bin/phpunit -v --coverage-clover build/logs/clover.xml; fi;
- if [ "${TRAVIS_PHP_VERSION}" == '7.1' ] && [ "${SYMFONY_VERSION}" == '3.4.*' ]; then travis_retry wget -q https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar && travis_retry php coveralls.phar -v; fi;
- if [ "${TRAVIS_PHP_VERSION}" != '7.1' ] || [ "${SYMFONY_VERSION}" != '4.4.*' ]; then vendor/bin/phpunit -v; fi;
- if [ "${TRAVIS_PHP_VERSION}" == '7.1' ] && [ "${SYMFONY_VERSION}" == '4.4.*' ]; then vendor/bin/phpunit -v --coverage-clover build/logs/clover.xml; fi;
- if [ "${TRAVIS_PHP_VERSION}" == '7.1' ] && [ "${SYMFONY_VERSION}" == '4.4.*' ]; then travis_retry wget -q https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar && travis_retry php coveralls.phar -v; fi;

notifications:
email:
Expand Down
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@
}
],
"require": {
"php": ">=5.5.9",
"symfony/symfony": "~2.7|~3.0|~4.0",
"php": ">=7.1.3",
"ext-gd": "*",
"ext-exif": "*",
"symfony/symfony": "4.4.*|5.0.*",
"intervention/image": "^2.3",
"twig/twig": "^1.28|^2.0",
"twig/twig": "^2.0",
"sybio/gif-frame-extractor": "^1.0",
"sybio/gif-creator": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0|^5.0",
"matthiasnoback/symfony-dependency-injection-test": "^1.0"
"phpunit/phpunit": "^7.0",
"matthiasnoback/symfony-dependency-injection-test": "^3.0|^4.0"
},
"autoload": {
"psr-4": {
Expand Down
20 changes: 2 additions & 18 deletions src/Controller/ImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,22 @@

use IngaLabs\Bundle\ImageBundle\Exception\ImageExceptionInterface;
use IngaLabs\Bundle\ImageBundle\ImageManager;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
* ImageController.
*
* @author Antal Áron <antalaron@antalaron.hu>
*/
class ImageController
{
/**
* @var ImageManager
*/
private $imageManager;

/**
* Constructor.
*
* @param ImageManager $imageManager
*/
public function __construct(ImageManager $imageManager)
{
$this->imageManager = $imageManager;
}

/**
* ShowAction.
*
* The main controller.
*
* @return Response
*/
public function showAction($hash, $size, $aspect)
public function showAction(string $hash, int $size, int $aspect): Response
{
try {
$image = $this->imageManager->getImageByHash($hash);
Expand Down
12 changes: 1 addition & 11 deletions src/DependencyInjection/Compiler/ConfigPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,14 @@ public function process(ContainerBuilder $container)
return;
}

if ($container->hasParameter('ingalabs_image.backend_type_orm')) {
$doctrine = 'doctrine';
} elseif ($container->hasParameter('ingalabs_image.backend_type_mongodb')) {
$doctrine = 'doctrine_mongodb';
} else {
throw new \RuntimeException(
'Either parameter "ingalabs_image.backend_type_orm" or '.
'"ingalabs_image.backend_type_mongodb" should be set.');
}

$config = [];
if ($container->hasParameter('ingalabs_image.config')) {
$config = $container->getParameter('ingalabs_image.config');
}

$container
->findDefinition('ingalabs_image.image_manager')
->replaceArgument(0, new Reference($doctrine, ContainerInterface::NULL_ON_INVALID_REFERENCE))
->replaceArgument(0, new Reference('doctrine', ContainerInterface::NULL_ON_INVALID_REFERENCE))
->replaceArgument(1, $config);

$container
Expand Down
12 changes: 0 additions & 12 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,23 @@
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* Configuration.
*
* @author Antal Áron <antalaron@antalaron.hu>
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('ingalabs_image');

$rootNode
->children()
->enumNode('doctrine_driver')
->values(['orm', 'mongodb'])
->defaultValue('orm')
->end()
->scalarNode('image_dir')
->defaultValue('%kernel.root_dir%/../web')
->end()
->scalarNode('prefix')
->defaultValue('/assets/images')
->end()
->scalarNode('driver')
->defaultValue('gd')
->end()
->booleanNode('mock_image')
->defaultValue('%kernel.debug%')
->end()
Expand Down
9 changes: 0 additions & 9 deletions src/DependencyInjection/IngaLabsImageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,21 @@
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
* IngaLabsImageExtension.
*
* @author Antal Áron <antalaron@antalaron.hu>
*/
class IngaLabsImageExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$container->setParameter('ingalabs_image.backend_type_'.$config['doctrine_driver'], true);
$container->setParameter('ingalabs_image.config', $config);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}

/**
* {@inheritdoc}
*/
public function getAlias()
{
return 'ingalabs_image';
Expand Down
2 changes: 0 additions & 2 deletions src/Exception/IOException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
namespace IngaLabs\Bundle\ImageBundle\Exception;

/**
* IOException.
*
* @author Antal Áron <antalaron@antalaron.hu>
*/
class IOException extends \RuntimeException implements ImageExceptionInterface
Expand Down
2 changes: 0 additions & 2 deletions src/Exception/ImageExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
namespace IngaLabs\Bundle\ImageBundle\Exception;

/**
* ImageExceptionInterface.
*
* @author Antal Áron <antalaron@antalaron.hu>
*/
interface ImageExceptionInterface
Expand Down
2 changes: 0 additions & 2 deletions src/Exception/ImageNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
namespace IngaLabs\Bundle\ImageBundle\Exception;

/**
* ImageNotFoundException.
*
* @author Antal Áron <antalaron@antalaron.hu>
*/
class ImageNotFoundException extends \RuntimeException implements ImageExceptionInterface
Expand Down
2 changes: 0 additions & 2 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
namespace IngaLabs\Bundle\ImageBundle\Exception;

/**
* InvalidArgumentException.
*
* @author Antal Áron <antalaron@antalaron.hu>
*/
class InvalidArgumentException extends \InvalidArgumentException implements ImageExceptionInterface
Expand Down
2 changes: 0 additions & 2 deletions src/Exception/LoaderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
namespace IngaLabs\Bundle\ImageBundle\Exception;

/**
* LoaderException.
*
* @author Antal Áron <antalaron@antalaron.hu>
*/
class LoaderException extends \RuntimeException implements ImageExceptionInterface
Expand Down
40 changes: 5 additions & 35 deletions src/Helper/GifImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,67 +10,37 @@
namespace IngaLabs\Bundle\ImageBundle\Helper;

/**
* GifImage.
*
* @author Antal Áron <antalaron@antalaron.hu>
*/
class GifImage
{
const MIME_TYPE = 'image/gif';

/**
* @var string
*/
private $content;

/**
* Constructor.
*
* @param string $content
*/
public function __construct($content = '')
public function __construct(string $content = '')
{
$this->content = $content;
}

/**
* Set content.
*
* @param string $content
*/
public function setContent($content)
public function setContent(string $content): self
{
$this->content = $content;

return $this;
}

/**
* Get content.
*
* @return string
*/
public function getContent()
public function getContent(): string
{
return $this->content;
}

/**
* Get mime.
*
* @return string
*/
public function mime()
public function mime(): string
{
return static::MIME_TYPE;
}

/**
* String conversion.
*
* @return string
*/
public function __toString()
public function __toString(): string
{
return $this->getContent();
}
Expand Down
Loading

0 comments on commit abcb3d0

Please sign in to comment.