diff --git a/src/Colors/Profile.php b/src/Colors/Profile.php index 37d9ce73..b6383509 100644 --- a/src/Colors/Profile.php +++ b/src/Colors/Profile.php @@ -9,4 +9,5 @@ use Intervention\Image\Interfaces\ProfileInterface; class Profile extends File implements ProfileInterface { + // } diff --git a/src/File.php b/src/File.php index a3ee914a..18cdb01f 100644 --- a/src/File.php +++ b/src/File.php @@ -29,6 +29,18 @@ class File implements FileInterface $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} * diff --git a/tests/Unit/FileTest.php b/tests/Unit/FileTest.php index a34c8230..d9344e0b 100644 --- a/tests/Unit/FileTest.php +++ b/tests/Unit/FileTest.php @@ -32,6 +32,13 @@ final class FileTest extends BaseTestCase $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 { $filename = __DIR__ . '/file_' . strval(hrtime(true)) . '.test';