class FileLock implements FileLockInterface

File lock.

Traits

LoggerAwareTrait

Methods

__construct( string $file, null|int $options = null, LoggerInterface $logger = null)

Construct file lock with file name and optional options bitmask and logger instance.

setOptions( int $options)

Assign the options bitmask to configure locking behavior.

bool
isAcquired()

Returns true if lock has been acquired.

bool
isShared()

Returns true if lock is shared.

bool
isExclusive()

Returns true if lock is exclusive.

bool
isBlocking()

Returns true if lock is blocking.

bool
isNonBlocking()

Returns true if lock is non blocking.

bool
hasResource()

Returns true if file handle is held.

resource
getResource()

Returns the file handle.

bool
acquire()

Try to acquire a file lock.

bool
release()

Try to release a file lock.

Details

at line line 54
final __construct( string $file, null|int $options = null, LoggerInterface $logger = null)

Construct file lock with file name and optional options bitmask and logger instance.

Parameters

string $file The path to the file to lock
null|int $options An options bitmark to configure locking behavior
LoggerInterface $logger A logger instance enables acquire/release logging

at line line 69
final setOptions( int $options)

Assign the options bitmask to configure locking behavior.

Parameters

int $options An options bitmark to configure locking behavior

Exceptions

InvalidOptionException If conflicting options are passed

at line line 87
final bool isAcquired()

Returns true if lock has been acquired.

Return Value

bool

at line line 97
final bool isShared()

Returns true if lock is shared.

Return Value

bool

at line line 107
final bool isExclusive()

Returns true if lock is exclusive.

Return Value

bool

at line line 117
final bool isBlocking()

Returns true if lock is blocking.

Return Value

bool

at line line 127
final bool isNonBlocking()

Returns true if lock is non blocking.

Return Value

bool

at line line 137
final bool hasResource()

Returns true if file handle is held.

Return Value

bool

at line line 147
final resource getResource()

Returns the file handle.

Return Value

resource

at line line 157
final bool acquire()

Try to acquire a file lock.

Return Value

bool

at line line 186
final bool release()

Try to release a file lock.

Return Value

bool