for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Dandelion\Lock;
trait LockTrait
{
/**
* @var \Symfony\Component\Lock\LockFactory
*/
private $lockFactory;
* @var \Symfony\Component\Lock\LockInterface|null
private $lock;
* @param string $identifier
*
* @return void
private function acquire(string $identifier): void
if ($this->lockFactory === null) {
return;
}
$this->lock = $this->lockFactory->createLock($identifier);
if (!$this->lock->acquire(true)) {
$this->lock = null;
private function release(): void
if ($this->lock === null) {
$this->lock->release();