<commit_before><?php

namespace Maidmaid\WebotBundle\Event;

use GuzzleHttp\Message\Response;
use NumberPlate\AbstractSearcherSubscriber;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\GenericEvent;

class SearcherSubscriber extends AbstractSearcherSubscriber
{
	/* @var $input InputInterface */
	private $input;
	
	/* @var $output OutputInterface */
	private $output;
	
	public function __construct(InputInterface $input, OutputInterface $output)
	{
		$this->input = $input;
		$this->output = $output;
	}
	
	public function onCookieInitialize(GenericEvent $e)
	{
		$cookies = $e->getSubject();
		$cookie = $cookies[0]['Name'] . '=' . $cookies[0]['Value'];
		$this->output->writeln(sprintf('cookie.initialize: <comment>%s</comment>', $cookie));

		// Sleep
		$seconds = rand($this->input->getOption('min-sleep'), $this->input->getOption('max-sleep'));
		$this->output->writeln(sprintf('sleep <comment>%s</comment> seconds', $seconds));
		sleep($seconds);
	}
	
	public function onCaptchaDownload(Event $e)
	{
		$this->output->writeln('captcha.download');
	}
	
	public function onCaptchaDecode(GenericEvent $e)
	{
		$this->output->writeln(sprintf('captcha.decode: <comment>%s</comment>', $e->getSubject()));
	}
	
	public function onSearchSend(GenericEvent $e)
	{
		/* @var $response Response */
		$response = $e->getSubject();
		$this->output->writeln(sprintf('search.send: <comment>%s</comment>', $response->getStatusCode() . ' ' . $response->getReasonPhrase()));
	}
	
	public function onErrorReturn(GenericEvent $e)
	{
		$this->output->writeln(sprintf('error.return: <error>%s</error>', $e->getSubject()));
			
		// Sleep
		$seconds = rand($this->input->getOption('min-sleep'), $this->input->getOption('max-sleep'));
		$this->output->writeln(sprintf('sleep <comment>%s</comment> seconds', $seconds));
		sleep($seconds);
	}
}<commit_msg>ajout d'une méthode sleep dans le subscriber<commit_after><?php

namespace Maidmaid\WebotBundle\Event;

use GuzzleHttp\Message\Response;
use NumberPlate\AbstractSearcherSubscriber;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\GenericEvent;

class SearcherSubscriber extends AbstractSearcherSubscriber
{
	/* @var $input InputInterface */
	private $input;
	
	/* @var $output OutputInterface */
	private $output;
	
	public function __construct(InputInterface $input, OutputInterface $output)
	{
		$this->input = $input;
		$this->output = $output;
	}
	
	public function onCookieInitialize(GenericEvent $e)
	{
		$cookies = $e->getSubject();
		$cookie = $cookies[0]['Name'] . '=' . $cookies[0]['Value'];
		$this->output->writeln(sprintf('cookie.initialize: <comment>%s</comment>', $cookie));
		$this->sleep();
	}
	
	public function onCaptchaDownload(Event $e)
	{
		$this->output->writeln('captcha.download');
	}
	
	public function onCaptchaDecode(GenericEvent $e)
	{
		$this->output->writeln(sprintf('captcha.decode: <comment>%s</comment>', $e->getSubject()));
	}
	
	public function onSearchSend(GenericEvent $e)
	{
		/* @var $response Response */
		$response = $e->getSubject();
		$this->output->writeln(sprintf('search.send: <comment>%s</comment>', $response->getStatusCode() . ' ' . $response->getReasonPhrase()));
	}
	
	public function onErrorReturn(GenericEvent $e)
	{
		$this->output->writeln(sprintf('error.return: <error>%s</error>', $e->getSubject()));
		$this->sleep();
	}
	
	protected function sleep()
	{
		$seconds = rand($this->input->getOption('min-sleep'), $this->input->getOption('max-sleep'));
		$this->output->writeln(sprintf('sleep <comment>%s</comment> seconds', $seconds));
		sleep($seconds);
	}
}
{'fraction_non_alphanumeric': 0.17866458007303077, 'fraction_numerical': 0.0010432968179447052, 'mean_word_length': 5.657986111111111, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5826841', 'n_tokens_mistral': 1282, 'n_tokens_neox': 1236, 'n_words': 203}