<commit_before><?php

namespace Indigo\Supervisor\EventListener;

use Indigo\Supervisor\Supervisor;
use Symfony\Component\Process\Process as SymfonyProcess;

class MemmonEventListener extends AbstractEventListener
{
	protected $supervisor;
	protected $program = array();
	protected $group = array();
	protected $any;
	protected $name = null;

	public function __construct(Supervisor $supervisor, array $program = array(), array $group = array(), $any, $name = null)
	{
		$this->supervisor = $supervisor;
		$this->program = $program;
		$this->group = $group;
		$this->any = $any;
		$this->name = $name;
	}

	protected function doListen(array $payload)
	{
		if (strpos($payload[0]['eventname'], 'TICK') == false) {
			return 0;
		}

		$processes = $this->supervisor->getAllProcess();

		foreach ($processes as $process) {
			$mem = $process->getMemUsage();

			if ($maxMem = $this->isListeningTo(array($process['name'], $pname), $this->programs) and $mem > $maxMem) {
				$this->restart($process, $mem);
			} elseif ($maxMem = $this->isListeningTo($process['group'], $this->groups) and $mem > $maxMem) {
				$this->restart($process, $mem);
			} elseif ($mem > intval($this->any)) {
				$this->restart($process, $mem);
			}
		}

		return 0;
	}

	protected function restart($process, $mem)
	{
		$process->restart();
	}

	protected function isListeningTo($what, $to = array())
	{
		if (is_array($what)) {
			foreach ($what as $w) {
				if (array_key_exists($w, $to)) {
					return $to[$w];
				}
			}
		} else {
			if (array_key_exists($what, $to)) {
				return $to[$what];
			}
		}

		return false;
	}
}<commit_msg>Tabs to spaces<commit_after><?php

namespace Indigo\Supervisor\EventListener;

use Indigo\Supervisor\Supervisor;
use Symfony\Component\Process\Process as SymfonyProcess;

class MemmonEventListener extends AbstractEventListener
{
    protected $supervisor;
    protected $program = array();
    protected $group = array();
    protected $any;
    protected $name = null;

    public function __construct(Supervisor $supervisor, array $program = array(), array $group = array(), $any, $name = null)
    {
        $this->supervisor = $supervisor;
        $this->program = $program;
        $this->group = $group;
        $this->any = $any;
        $this->name = $name;
    }

    protected function doListen(array $payload)
    {
        if (strpos($payload[0]['eventname'], 'TICK') == false) {
            return 0;
        }

        $processes = $this->supervisor->getAllProcess();

        foreach ($processes as $process) {
            $mem = $process->getMemUsage();

            if ($maxMem = $this->isListeningTo(array($process['name'], $pname), $this->programs) and $mem > $maxMem) {
                $this->restart($process, $mem);
            } elseif ($maxMem = $this->isListeningTo($process['group'], $this->groups) and $mem > $maxMem) {
                $this->restart($process, $mem);
            } elseif ($mem > intval($this->any)) {
                $this->restart($process, $mem);
            }
        }

        return 0;
    }

    protected function restart($process, $mem)
    {
        $process->restart();
    }

    protected function isListeningTo($what, $to = array())
    {
        if (is_array($what)) {
            foreach ($what as $w) {
                if (array_key_exists($w, $to)) {
                    return $to[$w];
                }
            }
        } else {
            if (array_key_exists($what, $to)) {
                return $to[$what];
            }
        }

        return false;
    }
}
{'fraction_non_alphanumeric': 0.1623907527488018, 'fraction_numerical': 0.0016915703411333521, 'mean_word_length': 2.7074190177638453, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '3953845', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1110, 'n_words': 246}