<commit_before><?php defined('SYSPATH') OR die('No direct access allowed.');
/**
 * Email module
 *
 * Ported from Kohana 2.2.3 Core to Kohana 3.0 module
 * 
 * Updated to use Swiftmailer 4.0.4
 *
 * @package    Core
 * @author     <NAME>
 * @copyright  (c) 2007-2008 Kohana Team
 * @license    http://kohanaphp.com/license.html
 */
class Email
{
	/**
	 * Creates a SwiftMailer instance.
	 *
	 * @param   string  DSN connection string
	 * @return  object  Swift object
	 */
	public static function get_transport($config = NULL)
	{
		if ( ! class_exists('Swift_Mailer', FALSE))
		{
			require Kohana::find_file('vendor', 'swiftmailer/lib/swift_required');
		}

		// Load default configuration
		($config === NULL) and $config = Kohana::$config->load('email');
		
		if ('smtp' === $config['driver'])
		{
			/**
			 * SMTP transport
			 */
			$port = empty($config['options']['port']) ? 25 : (int) $config['options']['port'];
			
			$transport = Swift_SmtpTransport::newInstance($config['options']['hostname'], $port);

			if ( ! empty($config['options']['encryption']))
			{
				$transport->setEncryption($config['options']['encryption']);
			}
			
			empty($config['options']['username']) or $transport->setUsername($config['options']['username']);
			empty($config['options']['password']) or $transport->setPassword($config['options']['password']);
			
			$transport->setTimeout(empty($config['options']['timeout']) ? 5 : (int) $config['options']['timeout']);
		}
		elseif ('sendmail' === $config['driver'])
		{
			/**
			 * Sendmail transport
			 */
			$transport = Swift_SendmailTransport::newInstance(empty($config['options']) ? "/usr/sbin/sendmail -bs" : $config['options']);
		}
		elseif('null' === $config['driver'])
		{
			/**
			 * Null transport
			 */
			$transport = Swift_NullTransport::newInstance();
		}
		else
		{
			/**
			 * Native transport (mail).
			 */
			$transport = Swift_MailTransport::newInstance($config['options']);
		}
		
		if (isset($config['logging']) AND $config['logging'])
		{
			/**
			 * Logs all outgoing email to the database. 
			 */
			$model = ORM::factory('email');
			
			$database_reporter = new Swift_Plugins_Pixel_Email_Logger_Database($model);
			$reporter          = new Swift_Plugins_ReporterPlugin($database_reporter);
				
			$transport->registerPlugin($reporter);
		}
		
		return $transport;
	}
} // End email<commit_msg>We need to return a new Swiftmailer instance here.<commit_after><?php defined('SYSPATH') OR die('No direct access allowed.');
/**
 * Email module
 *
 * Ported from Kohana 2.2.3 Core to Kohana 3.0 module
 * 
 * Updated to use Swiftmailer 4.0.4
 *
 * @package    Core
 * @author     <NAME>
 * @copyright  (c) 2007-2008 Kohana Team
 * @license    http://kohanaphp.com/license.html
 */
class Email
{
	/**
	 * Creates a SwiftMailer instance.
	 *
	 * @param   string  DSN connection string
	 * @return  object  Swift object
	 */
	public static function get_transport($config = NULL)
	{
		if ( ! class_exists('Swift_Mailer', FALSE))
		{
			require Kohana::find_file('vendor', 'swiftmailer/lib/swift_required');
		}

		// Load default configuration
		($config === NULL) and $config = Kohana::$config->load('email');
		
		if ('smtp' === $config['driver'])
		{
			/**
			 * SMTP transport
			 */
			$port = empty($config['options']['port']) ? 25 : (int) $config['options']['port'];
			
			$transport = Swift_SmtpTransport::newInstance($config['options']['hostname'], $port);

			if ( ! empty($config['options']['encryption']))
			{
				$transport->setEncryption($config['options']['encryption']);
			}
			
			empty($config['options']['username']) or $transport->setUsername($config['options']['username']);
			empty($config['options']['password']) or $transport->setPassword($config['options']['password']);
			
			$transport->setTimeout(empty($config['options']['timeout']) ? 5 : (int) $config['options']['timeout']);
		}
		elseif ('sendmail' === $config['driver'])
		{
			/**
			 * Sendmail transport
			 */
			$transport = Swift_SendmailTransport::newInstance(empty($config['options']) ? "/usr/sbin/sendmail -bs" : $config['options']);
		}
		elseif('null' === $config['driver'])
		{
			/**
			 * Null transport
			 */
			$transport = Swift_NullTransport::newInstance();
		}
		else
		{
			/**
			 * Native transport (mail).
			 */
			$transport = Swift_MailTransport::newInstance($config['options']);
		}
				
		if (isset($config['logging']) AND $config['logging'])
		{
			/**
			 * Logs all outgoing email to the database. 
			 */
			$model = ORM::factory('email');
			
			$database_reporter = new Swift_Plugins_Pixel_Email_Logger_Database($model);
			$reporter          = new Swift_Plugins_ReporterPlugin($database_reporter);
				
			$transport->registerPlugin($reporter);
		}
		
		return Swift_Mailer::newInstance($transport);
	}
} // End email
{'fraction_non_alphanumeric': 0.1847464671654198, 'fraction_numerical': 0.007896924355777223, 'mean_word_length': 3.813, 'pattern_counts': {'":': 0, '<': 7, '<?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': '759839', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1440, 'n_words': 287}