<?php namespace Jigsaw\Jigsaw;

use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;

class TemporaryFilesystem
{
    private $tempPath;
    private $filesystem;

    public function __construct($tempPath, $filesystem = null)
    {
        $this->tempPath = $tempPath;
        $this->filesystem = $filesystem ?: new Filesystem;
    }

    public function put($contents, $callback, $extension = '')
    {
        $path = $this->tempPath . '/' . Str::quickRandom(32) . $extension;
        $this->filesystem->put($path, $contents);
        $result = $callback($path);
        $this->filesystem->delete($path);
        return $result;
    }
}

<?php namespace Jigsaw\Jigsaw;

use Illuminate\Support\Str;

class TemporaryFilesystem
{
    private $tempPath;
    private $filesystem;

    public function __construct($tempPath, $filesystem = null)
    {
        $this->tempPath = $tempPath;
        $this->filesystem = $filesystem ?: new Filesystem;
    }

    public function put($contents, $callback, $extension = '')
    {
        $path = $this->tempPath . '/' . Str::quickRandom(32) . $extension;
        $this->filesystem->put($path, $contents);
        $result = $callback($path);
        $this->filesystem->delete($path);
        return $result;
    }
}

Use Jigsaw\Filesystem instead of Illuminate\Filesystem
Use Jigsaw\Filesystem instead of Illuminate\Filesystem
