<commit_before><?php

namespace TaskQueue;

use TaskQueue\Task\TaskInterface;
use TaskQueue\Log\LoggerInterface;
use TaskQueue\Log\NullLogger;

class TaskQueue implements TaskQueueInterface
{
    /**
     * @var \TaskQueue\TaskQueueInterface
     */
    protected $backend;

    /**
     * @var \TaskQueue\Log\LoggerInterface
     */
    protected $logger;

    /**
     * Constructor.
     *
     * @param \TaskQueue\TaskQueueInterface $backend
     * @param \TaskQueue\Log\LoggerInterface|null $logger
     */
    public function __construct(TaskQueueInterface $backend, LoggerInterface $logger = null)
    {
        $this->backend = $backend;
        $this->logger = $logger ?: new NullLogger();
    }

    /**
     * @return \TaskQueue\TaskQueueInterface
     */
    public function getBackend()
    {
        return $this->backend;
    }

    /**
     * @return Log\LoggerInterface|Log\NullLogger
     */
    public function getLogger()
    {
        return $this->logger;
    }

    /**
     * @see TaskQueueInterface::push()
     */
    public function push($task)
    {
        try {
            $this->backend->push($task);
        } catch (\Exception $e) {
            $this->logger->err(sprintf('Unable to push task %s: %s.', $task, $e->getMessage()));
            throw $e;
        }

        $this->logger->debug(sprintf('Task %s was successfully pushed.', $task));
    }

    /**
     * @see TaskQueueInterface::pop()
     */
    public function pop()
    {
        try {
            $task = $this->backend->pop();
        } catch (\Exception $e) {
            $this->logger->err(sprintf('Unable to pop task: %s.', $e->getMessage()));
            throw $e;
        }

        return $task;
    }

    /**
     * @see TaskQueueInterface::peek()
     */
    public function peek($limit = 1, $skip = 0)
    {
        try {
            $tasks = $this->backend->peek($limit, $skip);
        } catch (\Exception $e) {
            $this->logger->err(sprintf('Unable to peek task(s): %s.', $e->getMessage()));
            throw $e;
        }

        return $tasks;
    }
}<commit_msg>added TODO notice<commit_after><?php

namespace TaskQueue;

use TaskQueue\Task\TaskInterface;
use TaskQueue\Log\LoggerInterface;
use TaskQueue\Log\NullLogger;

class TaskQueue implements TaskQueueInterface
{
    /**
     * @var \TaskQueue\TaskQueueInterface
     */
    protected $backend;

    /**
     * @var \TaskQueue\Log\LoggerInterface
     */
    protected $logger;

    /**
     * Constructor.
     *
     * @param \TaskQueue\TaskQueueInterface $backend
     * @param \TaskQueue\Log\LoggerInterface|null $logger
     */
    public function __construct(TaskQueueInterface $backend, LoggerInterface $logger = null)
    {
        $this->backend = $backend;
        $this->logger = $logger ?: new NullLogger();
    }

    /**
     * @return \TaskQueue\TaskQueueInterface
     */
    public function getBackend()
    {
        return $this->backend;
    }

    /**
     * @return Log\LoggerInterface|Log\NullLogger
     */
    public function getLogger()
    {
        return $this->logger;
    }

    /**
     * TODO add TaskInterface type hinting (__toString is used)
     *
     * @see TaskQueueInterface::push()
     */
    public function push($task)
    {
        try {
            $this->backend->push($task);
        } catch (\Exception $e) {
            $this->logger->err(sprintf('Unable to push task %s: %s.', $task, $e->getMessage()));
            throw $e;
        }

        $this->logger->debug(sprintf('Task %s was successfully pushed.', $task));
    }

    /**
     * @see TaskQueueInterface::pop()
     */
    public function pop()
    {
        try {
            $task = $this->backend->pop();
        } catch (\Exception $e) {
            $this->logger->err(sprintf('Unable to pop task: %s.', $e->getMessage()));
            throw $e;
        }

        return $task;
    }

    /**
     * @see TaskQueueInterface::peek()
     */
    public function peek($limit = 1, $skip = 0)
    {
        try {
            $tasks = $this->backend->peek($limit, $skip);
        } catch (\Exception $e) {
            $this->logger->err(sprintf('Unable to peek task(s): %s.', $e->getMessage()));
            throw $e;
        }

        return $tasks;
    }
}
{'fraction_non_alphanumeric': 0.14494710781003825, 'fraction_numerical': 0.0009002925950934053, 'mean_word_length': 1.7347692307692308, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, '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': '213573', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1257, 'n_words': 264}