<commit_before><?php
namespace Kingsquare\Parser\Banking;

use Kingsquare\Parser\Banking;

/**
 * @package Kingsquare\Parser\Banking
 * @author Kingsquare (<EMAIL>)
 * @license http://opensource.org/licenses/MIT MIT
 */
class Mt940 extends Banking
{
    /** @var Banking\Mt940\Engine */
    protected $engine;

    /** @var bool */
    public static $removeIBAN = true; // defaults to true for BC

    /**
     * Parse the given string into an array of Banking\Statement objects
     *
     * @param string $string
     *
     * @return \Kingsquare\Banking\Statement[]
     */
    public function parse($string)
    {
        if (!empty($string)) {
            // load engine
            $this->engine = Banking\Mt940\Engine::__getInstance($string);
            if ($this->engine instanceof Banking\Mt940\Engine) {
                // parse using the engine
                return $this->engine->parse();
            }
        }

        return array();
    }
}
<commit_msg>allow injecting the engine into the parse method<commit_after><?php
namespace Kingsquare\Parser\Banking;

use Kingsquare\Parser\Banking;

/**
 * @package Kingsquare\Parser\Banking
 * @author Kingsquare (<EMAIL>)
 * @license http://opensource.org/licenses/MIT MIT
 */
class Mt940 extends Banking
{
    /** @var Banking\Mt940\Engine */
    protected $engine;

    /** @var bool */
    public static $removeIBAN = true; // defaults to true for BC

    /**
     * Parse the given string into an array of Banking\Statement objects
     *
     * @param string $string
     * @param Banking\Mt940\Engine $engine
     *
     * @return \Kingsquare\Banking\Statement[]
     */
    public function parse($string, Banking\Mt940\Engine $engine = null)
    {
        if (!empty($string)) {
            // load engine
            $this->engine = $engine || Banking\Mt940\Engine::__getInstance($string);
            if ($this->engine instanceof Banking\Mt940\Engine) {
                // parse using the engine
                $engine->loadString($string);
                return $this->engine->parse();
            }
        }

        return array();
    }
}

{'fraction_non_alphanumeric': 0.1274787535410765, 'fraction_numerical': 0.014164305949008499, 'mean_word_length': 2.176911544227886, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 14, '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': '1049949', 'n_tokens_mistral': 631, 'n_tokens_neox': 596, 'n_words': 151}