<commit_before><?php
/**
 * @package johnpancoast/data-migrator
 * @copyright (c) 2015 <NAME>
 * @author <NAME> <<EMAIL>>
 * @license MIT
 */

namespace Pancoast\DataMigrator;

use Pancoast\DataMigrator\Exception\HaltableModelIterationException;
use Pancoast\DataMigrator\Exception\IterationConstraintViolationException;

/**
 * Abstract migration model
 *
 * @author <NAME> <<EMAIL>>
 */
abstract class AbstractModel implements ModelInterface
{
    /**
     * @inheritDoc
     */
    abstract public function getFields();

    /**
     * @inheritDoc
     */
    public function createIterationInput(IterationDefinitionInterface $iterationDefinition, $iterationData)
    {
        return $iterationData;
    }

    /**
     * @inheritDoc
     * @see ModelInterface::begin()
     */
    public function begin()
    {
        // nothing to do by default. override at will.
    }

    /**
     * @inheritDoc
     * @see ModelInterface::end()
     */
    public function end()
    {
        // nothing to do by default. override at will.
    }

    /**
     * @inheritDoc
     * @see ModelInterface::beginIteration()
     */
    public function beginIteration(IterationDefinitionInterface $iterationDefinition, &$iterationInput, &$iterationOutput)
    {
        // nothing to do by default. override at will.
    }

    /**
     * @inheritDoc
     * @see ModelInterface::endIteration()
     */
    public function endIteration(IterationDefinitionInterface $iterationDefinition, $iterationOutput)
    {
        // nothing to do by default. override at will.
    }

    /**
     * @inheritDoc
     */
    public function handleIterationConstraintViolations(IterationDefinitionInterface $iterationDefinition, array $violationList)
    {
        $messages = [];

        foreach ($violationList as $violation) {
            $messages[] = sprintf('[%s] - %s', $violation->getFieldName(), $violation->getMessage());
        }

        throw new IterationConstraintViolationException(implode(', ', $messages));
    }

    /**
     * @inheritDoc
     */
    public function handleIterationException(IterationDefinitionInterface $iterationDefinition, \Exception $exception)
    {
        throw new HaltableModelIterationException(
            sprintf(
                'Iteration %s encountered an exception',
                $iterationDefinition->getIterationCount()
            ),
            0,
            $exception
        );
    }
}<commit_msg>Changed message for iteration exceptions<commit_after><?php
/**
 * @package johnpancoast/data-migrator
 * @copyright (c) 2015 <NAME>
 * @author <NAME> <<EMAIL>>
 * @license MIT
 */

namespace Pancoast\DataMigrator;

use Pancoast\DataMigrator\Exception\HaltableModelIterationException;
use Pancoast\DataMigrator\Exception\IterationConstraintViolationException;

/**
 * Abstract migration model
 *
 * @author <NAME> <<EMAIL>>
 */
abstract class AbstractModel implements ModelInterface
{
    /**
     * @inheritDoc
     */
    abstract public function getFields();

    /**
     * @inheritDoc
     */
    public function createIterationInput(IterationDefinitionInterface $iterationDefinition, $iterationData)
    {
        return $iterationData;
    }

    /**
     * @inheritDoc
     * @see ModelInterface::begin()
     */
    public function begin()
    {
        // nothing to do by default. override at will.
    }

    /**
     * @inheritDoc
     * @see ModelInterface::end()
     */
    public function end()
    {
        // nothing to do by default. override at will.
    }

    /**
     * @inheritDoc
     * @see ModelInterface::beginIteration()
     */
    public function beginIteration(IterationDefinitionInterface $iterationDefinition, &$iterationInput, &$iterationOutput)
    {
        // nothing to do by default. override at will.
    }

    /**
     * @inheritDoc
     * @see ModelInterface::endIteration()
     */
    public function endIteration(IterationDefinitionInterface $iterationDefinition, $iterationOutput)
    {
        // nothing to do by default. override at will.
    }

    /**
     * @inheritDoc
     */
    public function handleIterationConstraintViolations(IterationDefinitionInterface $iterationDefinition, array $violationList)
    {
        $messages = [];

        foreach ($violationList as $violation) {
            $messages[] = sprintf('[%s] - %s', $violation->getFieldName(), $violation->getMessage());
        }

        throw new IterationConstraintViolationException(implode(', ', $messages));
    }

    /**
     * @inheritDoc
     */
    public function handleIterationException(IterationDefinitionInterface $iterationDefinition, \Exception $exception)
    {
        throw new HaltableModelIterationException(
            sprintf(
                'Validation failed for iteration %s',
                $iterationDefinition->getIterationCount()
            ),
            0,
            $exception
        );
    }
}
{'fraction_non_alphanumeric': 0.11024908125765619, 'fraction_numerical': 0.002041649652919559, 'mean_word_length': 2.5837600585223117, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, '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': '1267378', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1314, 'n_words': 290}