<commit_before><?php
/**
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @since         1.3.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
namespace Cake\Shell\Task;

use Cake\Cache\Cache;
use Cake\Console\Shell;
use Cake\Core\Configure;
use Cake\Core\ConventionsTrait;
use Cake\Filesystem\File;

/**
 * Base class for Bake Tasks.
 *
 */
class BakeTask extends Shell {

	use ConventionsTrait;

/**
 * The pathFragment appended to the plugin/app path.
 *
 * @var string
 */
	public $pathFragment;

/**
 * Name of plugin
 *
 * @var string
 */
	public $plugin = null;

/**
 * The db connection being used for baking
 *
 * @var string
 */
	public $connection = null;

/**
 * Disable caching and enable debug for baking.
 * This forces the most current database schema to be used.
 *
 * @return void
 */
	public function startup() {
		Configure::write('debug', true);
		Cache::disable();
	}

/**
 * Initialize hook.
 *
 * Populates the connection property, which is useful for tasks of tasks.
 *
 * @return void
 */
	public function initialize() {
		if (empty($this->connection) && !empty($this->params['connection'])) {
			$this->connection = $this->params['connection'];
		}
	}

/**
 * Gets the path for output. Checks the plugin property
 * and returns the correct path.
 *
 * @return string Path to output.
 */
	public function getPath() {
		$path = APP . $this->pathFragment;
		if (isset($this->plugin)) {
			$path = $this->_pluginPath($this->plugin) . 'src/' . $this->pathFragment;
		}
		return str_replace('/', DS, $path);
	}

/**
 * Base execute method parses some parameters and sets some properties on the bake tasks.
 * call when overriding execute()
 *
 * @return void
 */
	public function main() {
		if (isset($this->params['plugin'])) {
			$this->plugin = $this->params['plugin'];
		}
		if (isset($this->params['connection'])) {
			$this->connection = $this->params['connection'];
		}
	}

/**
 * Executes an external shell command and pipes its output to the stdout
 *
 * @param string $command the command to execute
 * @return void
 * @throws \RuntimeException if any errors occurred during the execution
 */
	public function callProcess($command) {
		$descriptorSpec = [<commit_msg>Adding an error when an user attempts to use a plugin name that is using \ instead of the / for the plugins in the bake shell.<commit_after><?php
/**
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @since         1.3.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
namespace Cake\Shell\Task;

use Cake\Cache\Cache;
use Cake\Console\Shell;
use Cake\Core\Configure;
use Cake\Core\ConventionsTrait;
use Cake\Filesystem\File;

/**
 * Base class for Bake Tasks.
 *
 */
class BakeTask extends Shell {

	use ConventionsTrait;

/**
 * The pathFragment appended to the plugin/app path.
 *
 * @var string
 */
	public $pathFragment;

/**
 * Name of plugin
 *
 * @var string
 */
	public $plugin = null;

/**
 * The db connection being used for baking
 *
 * @var string
 */
	public $connection = null;

/**
 * Disable caching and enable debug for baking.
 * This forces the most current database schema to be used.
 *
 * @return void
 */
	public function startup() {
		Configure::write('debug', true);
		Cache::disable();
	}

/**
 * Initialize hook.
 *
 * Populates the connection property, which is useful for tasks of tasks.
 *
 * @return void
 */
	public function initialize() {
		if (empty($this->connection) && !empty($this->params['connection'])) {
			$this->connection = $this->params['connection'];
		}
	}

/**
 * Gets the path for output. Checks the plugin property
 * and returns the correct path.
 *
 * @return string Path to output.
 */
	public function getPath() {
		$path = APP . $this->pathFragment;
		if (isset($this->plugin)) {
			$path = $this->_pluginPath($this->plugin) . 'src/' . $this->pathFragment;
		}
		return str_replace('/', DS, $path);
	}

/**
 * Base execute method parses some parameters and sets some properties on the bake tasks.
 * call when overriding execute()
 *
 * @return void
 */
	public function main() {
		if (isset($this->params['plugin'])) {
			$this->plugin = $this->params['plugin'];
			if (strpos($this->plugin, '\\')) {
				return $this->error('Invalid plugin namespace separator, please use / instead of \ for plugins.');
			}
		}
		if (isset($this->params['connection'])) {
			$this->connection = $this->params['connection'];
		}
	}

/**
 * Executes an external shell command and pipes its output to the stdout
 *
 * @param string $command the command to execute
 * @return void
 * @throws \RuntimeException if any errors occurred during the execution
 */
	public function callProcess($command) {
		$descriptorSpec = [
{'fraction_non_alphanumeric': 0.13743056799856657, 'fraction_numerical': 0.0010750761512273786, 'mean_word_length': 3.519838056680162, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '746281', 'n_tokens_mistral': 1719, 'n_tokens_neox': 1614, 'n_words': 551}