class WriteMode extends AbstractParameter

Selects what to do if the file already exists. The default for this union is add.



Your intent when writing a file to some path. This is used to determine what constitutes a conflict and what the autorename strategy is.

In some situations, the conflict behavior is identical:

  1. If the target path doesn't contain anything, the file is always written; no conflict.
  2. If the target path contains a folder, it's always a conflict.
  3. If the target path contains a file with identical contents, nothing gets written; no conflict

The conflict checking differs in the case where there's a file at the target path with contents different from the contents you're trying to write

Constants

TAG_ADD

Used by {@link WriteMode::add()}

TAG_OVERWRITE

Used by {@link WriteMode::overwrite()}

TAG_UPDATE

Used by {@link WriteMode::update()}

Methods

array
jsonSerialize()

Specify data which should be serialized to JSON

string
__toString()

A shorthand for JSON-encoding parameters

static  WriteMode
add()

Never overwrite the existing file. The autorename strategy is to append a number to the file name. For example, "document.txt" might become "document (2).txt".

static  WriteMode
overwrite()

Always overwrite the existing file. The autorename strategy is the same as it is for add.

static  WriteMode
update( string $rev)

Overwrite if the given "rev" matches the existing file's "rev". The autorename strategy is to append the string "conflicted copy" to the file name. For example, "document.txt" might become "document (conflicted copy).txt" or "document (Panda's conflicted copy).txt".

Details

in AbstractParameter at line line 64
array jsonSerialize()

Specify data which should be serialized to JSON

Return Value

array data which can be serialized by json_encode, which is a value of any type other than a resource.

See also

http://php.net/manual/en/jsonserializable.jsonserialize.php

in AbstractParameter at line line 75
string __toString()

A shorthand for JSON-encoding parameters

Return Value

string

at line line 74
static WriteMode add()

Never overwrite the existing file. The autorename strategy is to append a number to the file name. For example, "document.txt" might become "document (2).txt".

Return Value

WriteMode

at line line 84
static WriteMode overwrite()

Always overwrite the existing file. The autorename strategy is the same as it is for add.

Return Value

WriteMode

at line line 99
static WriteMode update( string $rev)

Overwrite if the given "rev" matches the existing file's "rev". The autorename strategy is to append the string "conflicted copy" to the file name. For example, "document.txt" might become "document (conflicted copy).txt" or "document (Panda's conflicted copy).txt".

Parameters

string $rev The "rev" from the description

Return Value

WriteMode