PHP code example of holyshared / peridot-temporary-plugin

1. Go to this page and download the library: Download holyshared/peridot-temporary-plugin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

holyshared / peridot-temporary-plugin example snippets


use holyshared\peridot\temporary\TemporaryPlugin;

return function(EventEmitterInterface $emitter)
{
    TemporaryPlugin::create()->registerTo($emitter);
};

beforeEach(function() {
    $this->temp = $this->makeDirectory(); //return holyshared\peridot\temporary\TemporaryDirectory instance
});
it('create temporary directory', function() {
    expect($this->temp->exists())->toBeTrue();
});

beforeEach(function() {
    $this->temp = $this->makeDirectory(0755);
});
it('create temporary directory', function() {
    expect($this->temp->exists())->toBeTrue();
});

beforeEach(function() {
    $this->temp = $this->makeFile(); //return holyshared\peridot\temporary\TemporaryFile instance
});
it('create temporary file', function() {
    expect($this->temp->exists())->toBeTrue();
});

beforeEach(function() {
    $this->temp = $this->makeFile(0755);
});
it('create temporary file', function() {
    expect($this->temp->exists())->toBeTrue();
});

beforeEach(function() {
    $this->tempDirectory = $this->makeDirectory();
    $this->tempFile = $this->tempDirectory->createNewFile('report.txt');

    $this->tempFile->writeln('Hello world!!');
    $this->tempFile->writeln('Hello world!!');
});
afterEach(function() {
    $this->cleanUpTemporary();
});

beforeEach(function() {
    $tempDirectory = $this->makeDirectory();
    $tempFilePath = $tempDirectory->resolvePath('report.txt'); //File not created!!

    $tempFile = new SplFileObject($tempFilePath, 'w');
    $tempFile->fwrite('Hello world!!');
    $tempFile->fwrite('Hello world!!');
    $tempFile = null;
});