<commit_before><?php

/**
 * This file is part of the Lean Mapper library (http://www.leanmapper.com)
 *
 * Copyright (c) 2013 <NAME> (aka Tharos)
 *
 * For the full copyright and license information, please view the file
 * license-mit.txt that was distributed with this source code.
 */

namespace LeanMapper;

use LeanMapper\Exception\InvalidStateException;

/**
 * Default IMapper implementation
 *
 * @author <NAME>
 */
class DefaultMapper implements IMapper
{

	/** @var string */
	protected $defaultEntityNamespace = 'Model\Entity';

	/** @var string */
	protected $relationshipTableGlue = '_';


	/**
	 * @inheritdoc
	 */
	public function getPrimaryKey($table)
	{
		return 'id';
	}

	/**
	 * @inheritdoc
	 */
	public function getTable($entityClass)
	{
		return strtolower($this->trimNamespace($entityClass));
	}

	/**
	 * @inheritdoc
	 */
	public function getEntityClass($table, Row $row = null)
	{
		return $this->defaultEntityNamespace . '\\' . ucfirst($table);
	}

	/**
	 * @inheritdoc
	 */
	public function getColumn($entityClass, $field)
	{
		return $field;
	}

	/**
	 * @inheritdoc
	 */
	public function getEntityField($table, $column)
	{
		return $column;
	}

	/**
	 * @inheritdoc
	 */
	public function getRelationshipTable($sourceTable, $targetTable)
	{
		return $sourceTable . $this->relationshipTableGlue . $targetTable;
	}

	/**
	 * @inheritdoc
	 */
	public function getRelationshipColumn($sourceTable, $targetTable)
	{
		return $targetTable . '_' . $this->getPrimaryKey($targetTable);
	}

	/**
	 * @inheritdoc
	 */
	public function getTableByRepositoryClass($repositoryClass)
	{
		$matches = array();
		if (preg_match('#([a-z0-9]+)repository$#i', $repositoryClass, $matches)) {
			return strtolower($matches[1]);
		}
		throw new InvalidStateException('Cannot determine table name.');
	}

	////////////////////
	////////////////////

	/**
	 * @param $class
	 * @return string
	 */
	private function trimNamespace($class)
	{
		$class = explode('\\', $class);
		return end($class);
	}
	
}<commit_msg>Changed DefaultMapper::trimNamespace method visibility<commit_after><?php

/**
 * This file is part of the Lean Mapper library (http://www.leanmapper.com)
 *
 * Copyright (c) 2013 <NAME> (aka Tharos)
 *
 * For the full copyright and license information, please view the file
 * license-mit.txt that was distributed with this source code.
 */

namespace LeanMapper;

use LeanMapper\Exception\InvalidStateException;

/**
 * Default IMapper implementation
 *
 * @author <NAME>
 */
class DefaultMapper implements IMapper
{

	/** @var string */
	protected $defaultEntityNamespace = 'Model\Entity';

	/** @var string */
	protected $relationshipTableGlue = '_';


	/**
	 * @inheritdoc
	 */
	public function getPrimaryKey($table)
	{
		return 'id';
	}

	/**
	 * @inheritdoc
	 */
	public function getTable($entityClass)
	{
		return strtolower($this->trimNamespace($entityClass));
	}

	/**
	 * @inheritdoc
	 */
	public function getEntityClass($table, Row $row = null)
	{
		return $this->defaultEntityNamespace . '\\' . ucfirst($table);
	}

	/**
	 * @inheritdoc
	 */
	public function getColumn($entityClass, $field)
	{
		return $field;
	}

	/**
	 * @inheritdoc
	 */
	public function getEntityField($table, $column)
	{
		return $column;
	}

	/**
	 * @inheritdoc
	 */
	public function getRelationshipTable($sourceTable, $targetTable)
	{
		return $sourceTable . $this->relationshipTableGlue . $targetTable;
	}

	/**
	 * @inheritdoc
	 */
	public function getRelationshipColumn($sourceTable, $targetTable)
	{
		return $targetTable . '_' . $this->getPrimaryKey($targetTable);
	}

	/**
	 * @inheritdoc
	 */
	public function getTableByRepositoryClass($repositoryClass)
	{
		$matches = array();
		if (preg_match('#([a-z0-9]+)repository$#i', $repositoryClass, $matches)) {
			return strtolower($matches[1]);
		}
		throw new InvalidStateException('Cannot determine table name.');
	}

	/**
	 * @param $class
	 * @return string
	 */
	protected function trimNamespace($class)
	{
		$class = explode('\\', $class);
		return end($class);
	}

}
{'fraction_non_alphanumeric': 0.15827338129496402, 'fraction_numerical': 0.0034730836020838503, 'mean_word_length': 3.6451612903225805, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5496941', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1254, 'n_words': 285}