mirror of
https://github.com/Intervention/image.git
synced 2025-08-23 05:52:47 +02:00
Add File::fromPath()
This commit is contained in:
@@ -9,4 +9,5 @@ use Intervention\Image\Interfaces\ProfileInterface;
|
|||||||
|
|
||||||
class Profile extends File implements ProfileInterface
|
class Profile extends File implements ProfileInterface
|
||||||
{
|
{
|
||||||
|
//
|
||||||
}
|
}
|
||||||
|
12
src/File.php
12
src/File.php
@@ -29,6 +29,18 @@ class File implements FileInterface
|
|||||||
$this->pointer = $this->buildFilePointer($data);
|
$this->pointer = $this->buildFilePointer($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create file object from path in file system
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @return File
|
||||||
|
*/
|
||||||
|
public static function fromPath(string $path): self
|
||||||
|
{
|
||||||
|
return new self(fopen($path, 'r'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
|
@@ -32,6 +32,13 @@ final class FileTest extends BaseTestCase
|
|||||||
$this->assertInstanceOf(File::class, $file);
|
$this->assertInstanceOf(File::class, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFromPath(): void
|
||||||
|
{
|
||||||
|
$file = File::fromPath($this->getTestResourcePath());
|
||||||
|
$this->assertInstanceOf(File::class, $file);
|
||||||
|
$this->assertTrue($file->size() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
public function testSave(): void
|
public function testSave(): void
|
||||||
{
|
{
|
||||||
$filename = __DIR__ . '/file_' . strval(hrtime(true)) . '.test';
|
$filename = __DIR__ . '/file_' . strval(hrtime(true)) . '.test';
|
||||||
|
Reference in New Issue
Block a user