mirror of
https://github.com/Intervention/image.git
synced 2025-08-13 09:24:05 +02:00
Support creating Image from SplFileInfo object
This commit is contained in:
@@ -87,6 +87,16 @@ abstract class AbstractDecoder
|
|||||||
return is_a($this->data, '\Intervention\Image\Image');
|
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
|
* Determines if current data is Symfony UploadedFile component
|
||||||
*
|
*
|
||||||
@@ -198,7 +208,7 @@ abstract class AbstractDecoder
|
|||||||
case $this->isInterventionImage():
|
case $this->isInterventionImage():
|
||||||
return $this->initFromInterventionImage($this->data);
|
return $this->initFromInterventionImage($this->data);
|
||||||
|
|
||||||
case $this->isSymfonyUpload():
|
case $this->isSplFileInfo():
|
||||||
return $this->initFromPath($this->data->getRealPath());
|
return $this->initFromPath($this->data->getRealPath());
|
||||||
|
|
||||||
case $this->isBinary():
|
case $this->isBinary():
|
||||||
|
@@ -89,6 +89,19 @@ class AbstractDecoderTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertTrue($source->isInterventionImage());
|
$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()
|
public function testIsSymfonyUpload()
|
||||||
{
|
{
|
||||||
$source = $this->getTestDecoder(1);
|
$source = $this->getTestDecoder(1);
|
||||||
|
Reference in New Issue
Block a user