<commit_before><?php

namespace SwaggerGen\Swagger;

/**
 * Common foundation for all Swagger objects, handling the overall generator
 * structure, extensions and a few generic services.
 *
 * @package    SwaggerGen
 * @author     <NAME> <<EMAIL>>
 * @copyright  2014-2015 <NAME>
 * @license    https://opensource.org/licenses/MIT MIT
 */
abstract class AbstractObject
{

	private static $mime_types = array(
		'fileform' => 'multipart/form-data',
		'form' => 'application/x-www-form-urlencoded',
		'json' => 'application/json',
		'text' => 'text/plain',
		'utf8' => 'text/plain; charset=utf-8',
		'yml' => 'application/x-yaml',
		'yaml' => 'application/x-yaml',
		'php' => 'text/x-php',
		'xml' => 'text/xml',
	);

	/**
	 * @var AbstractObject
	 */
	private $parent;

	/**
	 * Map of extensions and their (trimmed) values
	 * @var string[]
	 */
	private $extensions = array();

	public function __construct(AbstractObject $parent = null)
	{
		$this->parent = $parent;
	}

	/**
	 * @return AbstractObject
	 */
	protected function getParent()
	{
		return $this->parent;
	}

	protected function getParentClass($classname)
	{
		if (is_a($this, $classname)) {
			return $this;
		}
		return $this->parent->getParentClass($classname);
	}

	/**
	 * @return SwaggerGen\Swagger
	 */
	protected function getRoot()
	{
		return $this->parent->getRoot();
	}

	/**
	 * @param string $command
	 * @param string $data
	 * @return AbstractObject
	 */
	public function handleCommand($command, $data = null)
	{
		if (strtolower(substr($command, 0, 2)) === 'x-') {
			$this->extensions[$command] = empty($data) ? $data : trim($data);
			return $this;
		}

		return false;
	}

	/**
	 * @return array
	 */
	public function toArray()
	{
		return $this->extensions;
	}

	/**
	 * Translate consumes from shortcuts
	 * @param String[] $mimeTypes
	 * @return String[]
	 */
	protected static function translateMimeTypes(Array $mimeTypes)
	{
		foreach ($mimeTypes as &$mimeType) {
			if (isset(self::$mime_types[strtolower($mimeType)])) {
				$mimeType = self::$mime_types[strtolower($mimeType)];
			}
		}

		return $mimeTypes;
	}<commit_msg>Minor compatibility fix<commit_after><?php

namespace SwaggerGen\Swagger;

/**
 * Common foundation for all Swagger objects, handling the overall generator
 * structure, extensions and a few generic services.
 *
 * @package    SwaggerGen
 * @author     <NAME> <<EMAIL>>
 * @copyright  2014-2015 <NAME>
 * @license    https://opensource.org/licenses/MIT MIT
 */
abstract class AbstractObject
{

	private static $mime_types = array(
		'fileform' => 'multipart/form-data',
		'form' => 'application/x-www-form-urlencoded',
		'json' => 'application/json',
		'text' => 'text/plain',
		'utf8' => 'text/plain; charset=utf-8',
		'yml' => 'application/x-yaml',
		'yaml' => 'application/x-yaml',
		'php' => 'text/x-php',
		'xml' => 'text/xml',
	);

	/**
	 * @var AbstractObject
	 */
	private $parent;

	/**
	 * Map of extensions and their (trimmed) values
	 * @var string[]
	 */
	private $extensions = array();

	public function __construct(AbstractObject $parent = null)
	{
		$this->parent = $parent;
	}

	/**
	 * @return AbstractObject
	 */
	protected function getParent()
	{
		return $this->parent;
	}

	protected function getParentClass($classname)
	{
		if (is_a($this, $classname)) {
			return $this;
		}
		return $this->parent->getParentClass($classname);
	}

	/**
	 * @return SwaggerGen\Swagger
	 */
	protected function getRoot()
	{
		return $this->parent->getRoot();
	}

	/**
	 * @param string $command
	 * @param string $data
	 * @return AbstractObject
	 */
	public function handleCommand($command, $data = null)
	{
		if (strtolower(substr($command, 0, 2)) === 'x-') {
			$this->extensions[$command] = empty($data) ? $data : trim($data);
			return $this;
		}

		return false;
	}

	/**
	 * @return array
	 */
	public function toArray()
	{
		return $this->extensions;
	}

	/**
	 * Translate consumes from shortcuts
	 * @param String[] $mimeTypes
	 * @return String[]
	 */
	protected static function translateMimeTypes($mimeTypes)
	{
		foreach ($mimeTypes as &$mimeType) {
			if (isset(self::$mime_types[strtolower($mimeType)])) {
				$mimeType = self::$mime_types[strtolower($mimeType)];
			}
		}

		return $mimeTypes;
	}
{'fraction_non_alphanumeric': 0.1673758865248227, 'fraction_numerical': 0.005673758865248227, 'mean_word_length': 3.6392543859649122, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 45, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, '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': '4807207', 'n_tokens_mistral': 1574, 'n_tokens_neox': 1398, 'n_words': 323}