Kahlan\Dir\Dir::tempnam PHP Method

tempnam() public static method

Creates a directory with unique file name.
See also: http://php.net/manual/en/function.tempnam.php
public static tempnam ( string $path = null, string $prefix = '' ) : string
$path string The directory where the temporary filename will be created.
$prefix string The prefix of the generated temporary filename.
return string
    public static function tempnam($path = null, $prefix = '')
    {
        if ($path === null) {
            $path = sys_get_temp_dir();
        }
        if ($tempfile = tempnam($path, $prefix)) {
            unlink($tempfile);
            mkdir($tempfile);
        }
        return $tempfile;
    }

Usage Example

コード例 #1
0
ファイル: InterceptorSpec.php プロジェクト: Ilyes512/kahlan
     afterEach(function () {
         Dir::remove($this->temp);
     });
     it("clears the cache", function () {
         $this->interceptor->clearCache();
         expect(file_exists($this->customCachePath))->toBe(false);
     });
     it("bails out if the cache has already been cleared", function () {
         $this->interceptor->clearCache();
         $this->interceptor->clearCache();
         expect(file_exists($this->customCachePath))->toBe(false);
     });
 });
 describe("->watch()/unwatch()", function () {
     it("add some file to be watched", function () {
         $this->temp = Dir::tempnam(null, 'cache');
         touch($this->temp . DS . 'watched1.php');
         touch($this->temp . DS . 'watched2.php');
         $watched = [$this->temp . DS . 'watched1.php', $this->temp . DS . 'watched2.php'];
         $this->interceptor = Interceptor::patch(['cachePath' => $this->cachePath]);
         $this->interceptor->watch($this->temp . DS . 'watched1.php');
         expect($this->interceptor->watched())->toBe([$watched[0]]);
         $this->interceptor->watch($this->temp . DS . 'watched2.php');
         expect($this->interceptor->watched())->toBe($watched);
         $this->interceptor->unwatch($this->temp . DS . 'watched1.php');
         expect($this->interceptor->watched())->toBe([$watched[1]]);
         $this->interceptor->unwatch($this->temp . DS . 'watched2.php');
         expect($this->interceptor->watched())->toBe([]);
         Dir::remove($this->temp);
     });
 });
All Usage Examples Of Kahlan\Dir\Dir::tempnam