Skip to content

Instantly share code, notes, and snippets.

View rgeraads's full-sized avatar
🏳️‍🌈

Randy Geraads rgeraads

🏳️‍🌈
  • Netherlands
View GitHub Profile
@rgeraads
rgeraads / LockFile.php
Last active August 18, 2023 11:58
Quick implementation of a lock via file
<?php declare(strict_types=1);
final class LockFile
{
private const LOCK_EXTENSION = '.lock';
private readonly string $fileName;
public function __construct(string $fileName, private readonly int $duration)
{
$this->fileName = $fileName . self::LOCK_EXTENSION;
@rgeraads
rgeraads / TempFile.php
Last active August 18, 2023 11:41
Temporary file for when a file path is required
<?php declare(strict_types=1);
final class TempFile
{
/** @var resource */
private $fileHandle;
/**
* @param resource $fileHandle
*/