<commit_before><?php
namespace Metaphore;

use Metaphore\Store\LockStoreInterface;

class LockManager
{
    protected $lockStore;

    protected $acquiredLocks = [];

    public function __construct(LockStoreInterface $lockStore)
    {
        $this->lockStore = $lockStore;
    }

    public function __destruct()
    {
        // release lock that have been acquired but not released for some reason
        foreach ($this->acquiredLocks as $key => $true) {
            $this->release($key);
            unset($this->acquiredLocks[$key]);
        }
    }

    protected function prepareLockKey($key)
    {
        return sprintf('%s.lock', $key);
    }

    public function acquire($key, $lockTtl)
    {
        $result = $this->lockStore->add($this->prepareLockKey($key), 1, $lockTtl);

        if ($result) {
            $this->acquiredLocks[$key] = true;
        }

        return $result;
    }
<commit_msg>Lock manager: no need to unset property...<commit_after><?php
namespace Metaphore;

use Metaphore\Store\LockStoreInterface;

class LockManager
{
    protected $lockStore;

    protected $acquiredLocks = [];

    public function __construct(LockStoreInterface $lockStore)
    {
        $this->lockStore = $lockStore;
    }

    public function __destruct()
    {
        // release lock that have been acquired but not released for some reason
        foreach ($this->acquiredLocks as $key => $true) {
            $this->release($key);
        }
    }

    protected function prepareLockKey($key)
    {
        return sprintf('%s.lock', $key);
    }

    public function acquire($key, $lockTtl)
    {
        $result = $this->lockStore->add($this->prepareLockKey($key), 1, $lockTtl);

        if ($result) {
            $this->acquiredLocks[$key] = true;
        }

        return $result;
    }

{'fraction_non_alphanumeric': 0.12555309734513273, 'fraction_numerical': 0.0011061946902654867, 'mean_word_length': 2.4391634980988592, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7515660', 'n_tokens_mistral': 547, 'n_tokens_neox': 527, 'n_words': 123}