1
0
mirror of https://github.com/Intervention/image.git synced 2025-02-06 22:00:38 +01:00

Merge pull request #216 from jwpage/splfile_support

SplFileInfo support
This commit is contained in:
Oliver Vogel 2014-08-28 09:32:57 +02:00
commit 3d0dafa7f9
3 changed files with 25 additions and 2 deletions

View File

@ -17,7 +17,7 @@
},
"require-dev": {
"phpunit/phpunit": "3.*",
"mockery/mockery": "0.9.*"
"mockery/mockery": "0.9.*@dev"
},
"suggest": {
"ext-gd": "to use GD library based image processing.",

View File

@ -87,6 +87,16 @@ abstract class AbstractDecoder
return is_a($this->data, '\Intervention\Image\Image');
}
/**
* Determines if current data is SplFileInfo object
*
* @return boolean
*/
public function isSplFileInfo()
{
return is_a($this->data, 'SplFileInfo');
}
/**
* Determines if current data is Symfony UploadedFile component
*
@ -198,7 +208,7 @@ abstract class AbstractDecoder
case $this->isInterventionImage():
return $this->initFromInterventionImage($this->data);
case $this->isSymfonyUpload():
case $this->isSplFileInfo():
return $this->initFromPath($this->data->getRealPath());
case $this->isBinary():

View File

@ -89,6 +89,19 @@ class AbstractDecoderTest extends PHPUnit_Framework_TestCase
$this->assertTrue($source->isInterventionImage());
}
public function testIsSplFileInfo()
{
$source = $this->getTestDecoder(1);
$this->assertFalse($source->isSplFileInfo());
$img = Mockery::mock('SplFileInfo');
$source = $this->getTestDecoder($img);
$this->assertTrue($source->isSplFileInfo());
$img = Mockery::mock('Symfony\Component\HttpFoundation\File\UploadedFile', 'SplFileInfo');
$this->assertTrue($source->isSplFileInfo());
}
public function testIsSymfonyUpload()
{
$source = $this->getTestDecoder(1);