<commit_before><?php

namespace Difra;

abstract class Plugin {

	private $class;
	private $enabled = false;
	private $path = '';

	static public function getInstance() {

		static $_self = array();
		$class = get_called_class();
		return !empty( $_self[$class] ) ? $_self[$class] : $_self[$class] = new $class;
	}

	final function __construct() {

		$this->class = get_class( $this );
	}

	public function getRequirements() {

		return property_exists( $this, 'require' ) ? $this->require : null;
	}

	abstract public function init();

	public function isEnabled() {

		return $this->enabled;
	}

	public function enable() {

		if( $this->enabled ) {
			return;
		}
		$this->enabled = true;
		if( $requirements = $this->getRequirements() ) {
			$plugger = Plugger::getInstance();
			$plugins = $plugger->getAllPlugins();
			foreach( $requirements as $req ) {
				if( !isset( $plugins[$req] ) ) {
					throw new Exception( "Plugin $req is required by $this->class, but it is not available!" );
				}
				$plugins[$req]->enable();
			}
		}
		$this->init();
	}

	public function getPath() {

		if( !$this->path ) {
			$reflection = new \ReflectionClass( $this );
			$this->path = dirname( $reflection->getFileName() );
		}
		return $this->path;
	}
	/*
	public function dispatch() {

		$class = substr( get_class( $this ), 1 );
		$method = 'dispatch';
		if( class_exists( $class ) ) {
			if( method_exists( $class, $method ) ) {
				$instance = call_user_func( array( $class, 'getInstance' ) );
				$instance->dispatch();
			}
		}
	}
	*/<commit_msg>Поправлена страница общей информации в админке (после переделки плагинов).<commit_after><?php

namespace Difra;

abstract class Plugin {

	private $class;
	private $name = null;
	private $enabled = false;
	private $path = '';

	static public function getInstance() {

		static $_self = array();
		$class = get_called_class();
		return !empty( $_self[$class] ) ? $_self[$class] : $_self[$class] = new $class;
	}

	final function __construct() {

		$this->class = get_class( $this );
	}

	public function getRequirements() {

		return property_exists( $this, 'require' ) ? $this->require : null;
	}

	abstract public function init();

	public function isEnabled() {

		return $this->enabled;
	}

	public function enable() {

		if( $this->enabled ) {
			return;
		}
		$this->enabled = true;
		if( $requirements = $this->getRequirements() ) {
			$plugger = Plugger::getInstance();
			$plugins = $plugger->getAllPlugins();
			foreach( $requirements as $req ) {
				if( !isset( $plugins[$req] ) ) {
					throw new Exception( "Plugin $req is required by $this->class, but it is not available!" );
				}
				$plugins[$req]->enable();
			}
		}
		$this->init();
	}

	public function getPath() {

		if( !$this->path ) {
			$reflection = new \ReflectionClass( $this );
			$this->path = dirname( $reflection->getFileName() );
		}
		return $this->path;
	}

	public function getName() {

		if( !$this->name ) {
			$this->name = basename( dirname( str_replace( '\\', '/', $this->class ) ) );
		}
		return $this->name;
	}
	/*
	public function dispatch() {

		$class = substr( get_class( $this ), 1 );
		$method = 'dispatch';
		if( class_exists( $class ) ) {
			if( method_exists( $class, $method ) ) {
				$instance = call_user_func( array( $class, 'getInstance' ) );
				$instance->dispatch();
			}
		}
	}
	*/
{'fraction_non_alphanumeric': 0.17280622941000298, 'fraction_numerical': 0.0005989817310572028, 'mean_word_length': 3.489247311827957, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '2833877', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1131, 'n_words': 279}