<commit_before><?php
/**
 * Created by PhpStorm.
 * User: daedeloth
 * Date: 21/05/15
 * Time: 0:25
 */

namespace i18nTracker\Mappers;


use i18nTracker\Collections\ResourceCollection;
use i18nTracker\MapperFactory;
use i18nTracker\Models\Bundle;
use i18nTracker\Models\Project;
use i18nTracker\Models\Resource;
use Neuron\DB\Query;

class ResourceMapper
	extends \Neuron\Mappers\BaseMapper {

	/**
	 * @param Bundle $bundle
	 * @param $token
	 * @return \i18nTracker\Models\Resource|null
	 */
	public function getFromToken (Bundle $bundle, $token) {
		return $this->getSingle (
			Query::select (
				'resources',
				array ('*'),
				array (
					'bundle_id' => $bundle->getId (),
					'resource_token' => $token
				)
			)->execute ()
		);
	}

	/**
	 * @param \i18nTracker\Models\Resource $resource
	 * @return \i18nTracker\Models\Resource
	 */
	public function touch (Resource $resource) {

		if ($resource->getId ()) {
			$this->update ($resource);
		}<commit_msg>Making the tracker case sensitive.<commit_after><?php
/**
 * Created by PhpStorm.
 * User: daedeloth
 * Date: 21/05/15
 * Time: 0:25
 */

namespace i18nTracker\Mappers;


use i18nTracker\Collections\ResourceCollection;
use i18nTracker\MapperFactory;
use i18nTracker\Models\Bundle;
use i18nTracker\Models\Resource;
use Neuron\DB\Query;

class ResourceMapper
	extends \Neuron\Mappers\BaseMapper {

	/**
	 * @param Bundle $bundle
	 * @param $token
	 * @return \i18nTracker\Models\Resource|null
	 */
	public function getFromToken (Bundle $bundle, $token) {

		$query = new Query
		("
			SELECT
				*
			FROM
				resources
			WHERE
				bundle_id = ? AND
				BINARY resource_token = ?
		");

		$query->bindValue (1, $bundle->getId ());
		$query->bindValue (2, $token);

		return $this->getSingle ($query->execute ());
	}

	/**
	 * @param \i18nTracker\Models\Resource $resource
	 * @return \i18nTracker\Models\Resource
	 */
	public function touch (Resource $resource) {

		if ($resource->getId ()) {
			$this->update ($resource);
		}
{'fraction_non_alphanumeric': 0.14478957915831664, 'fraction_numerical': 0.027054108216432865, 'mean_word_length': 3.5697940503432495, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '4618122', 'n_tokens_mistral': 786, 'n_tokens_neox': 672, 'n_words': 143}