Skip to content

Commit

Permalink
Require filename
Browse files Browse the repository at this point in the history
On second thought, a filename should be required, otherwise the object would need to be serialized and sent to another process to be of any use.
  • Loading branch information
trowski committed Nov 29, 2017
1 parent 19d6af2 commit 2443b33
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions lib/FileMutex.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,9 @@ class FileMutex implements Mutex {
/**
* Creates a new mutex.
*
* @param string|null Optional file name. If one is not provided a temporary file is created in the system temporary
* file directory.
* @param string|null
*/
public function __construct(string $fileName = null) {
if ($fileName === null) {
$fileName = \tempnam(\sys_get_temp_dir(), 'mutex-') . '.lock';
}

public function __construct(string $fileName) {
$this->fileName = $fileName;
}

Expand Down
2 changes: 1 addition & 1 deletion test/FileMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

class FileMutexTest extends AbstractMutexTest {
public function createMutex(): Mutex {
return new FileMutex;
return new FileMutex(\tempnam(\sys_get_temp_dir(), 'mutex-') . '.lock');
}
}

0 comments on commit 2443b33

Please sign in to comment.