Writer

Writes stuff to the filesystem.

class Writer
use LoggerAwareTrait
Copyright
2016 Appertly
License
Apache-2.0

Constructors / Destructors

Public
ReturnsSignature and Description
void
__construct(LoggerInterface $logger)

Creates a new Writer.

Instance Methods

Public
ReturnsSignature and Description
void
copy(string $source, string $destination)

Copies a file from one place to another.

void
mkdir(string $path)

Creates a directory; does nothing if path already exists

Awaitable<mixed>
write(string $filename, XHPRoot $contents)

Writes a file.

Method Details

__construct

public function __construct(LoggerInterface $logger)

Creates a new Writer.

Parameters
NameTypeDescription
$loggerLoggerInterface

The logger

copy

public function copy(string $source, string $destination)

Copies a file from one place to another.

Parameters
NameTypeDescription
$sourcestring

The source file

$destinationstring

The destination

mkdir

public function mkdir(string $path)

Creates a directory; does nothing if path already exists

Parameters
NameTypeDescription
$pathstring

The path to create

Throws
TypeConditions
IoException

if anything goes wrong or if $path is a file

write

public function write(string $filename, XHPRoot $contents)

Writes a file.

Parameters
NameTypeDescription
$filenamestring

The file to write

$contentsXHPRoot

The contents to export

Returns
TypeDescription
Awaitable<mixed>
Throws
TypeConditions
IoException

if anything goes wrong