public function onlyOne($tempDir = null, callable $whenOverlapping = null)
    {
        if ($tempDir === null || !is_dir($tempDir)) {
            $tempDir = $this->tempDir;
        }
        $this->lockFile = implode('/', [
            trim($tempDir),
            trim($this->id) . '.lock',
        ]);
        if ($whenOverlapping) {
            $this->whenOverlapping = $whenOverlapping;
        } else {
            $this->whenOverlapping = function () {
                return false;
            };
        }

        return $this;
    }
public function onlyOne($tempDir = null, callable $whenOverlapping = null)
    {
        if ($tempDir === null || !is_dir($tempDir)) {
            $tempDir = $this->tempDir;
        }
        $this->lockFile = implode('/', [
            trim($tempDir),
            trim($this->id) . '.lock',
        ]);
        if ($whenOverlapping) {
            $this->whenOverlapping = $whenOverlapping;
        } else {
            $this->whenOverlapping = function () {
                return false;
            };
        }

        return $this;
    }
public function onlyOne ( $ tempDir = null , callable $ whenOverlapping = null ) { if ( $ tempDir === null || ! is_dir ( $ tempDir ) ) { $ tempDir = $ this -> tempDir ; } $ this -> lockFile = implode ( '/' , [ trim ( $ tempDir ) , trim ( $ this -> id ) . '.lock' , ] ) ; if ( $ whenOverlapping ) { $ this -> whenOverlapping = $ whenOverlapping ; } else { $ this -> whenOverlapping = function ( ) { return false ; } ; } return $ this ; }
This will prevent the Job from overlapping.
It prevents another instance of the same Job of
being executed if the previous is still running.
The job id is used as a filename for the lock file.

@param  string $tempDir The directory path for the lock files
@param  callable $whenOverlapping A callback to ignore job overlapping
@return self
This will prevent the Job from overlapping . It prevents another instance of the same Job of being executed if the previous is still running . The job id is used as a filename for the lock file .