<commit_before><?php
/**
 * Pop PHP Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.TXT.
 * It is also available through the world-wide-web at this URL:
 * http://www.popphp.org/LICENSE.TXT
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to <EMAIL> so we can send you a copy immediately.
 *
 * @category   Pop
 * @package    Pop_Log
 * @author     <NAME>, III <<EMAIL>>
 * @copyright  Copyright (c) 2009-2012 Moc 10 Media, LLC. (http://www.moc10media.com)
 * @license    http://www.popphp.org/LICENSE.TXT     New BSD License
 */

/**
 * @namespace
 */
namespace Pop\Log\Writer;

use Pop\Mail\Mail as PopMail,
    Pop\Validator\Validator\Email;

/**
 * This is the Db writer class for the Log component.
 *
 * @category   Pop
 * @package    Pop_Log
 * @author     <NAME>, III <<EMAIL>>
 * @copyright  Copyright (c) 2009-2012 Moc 10 Media, LLC. (http://www.moc10media.com)
 * @license    http://www.popphp.org/LICENSE.TXT     New BSD License
 * @version    1.1.0
 */
class Mail implements WriterInterface
{

    /**
     * Array of emails in which to send the log messages
     * @var array
     */
    protected $emails = array();

    /**
     * Constructor
     *
     * Instantiate the Mail writer object.
     *
     * @param  array $emails
     * @throws Exception
     * @return \Pop\Log\Writer\Mail
     */
    public function __construct(array $emails)
    {
        if (count($emails) == 0) {
            throw new Exception('Error: There must be at least one email address passed.');
        }

        $validator = new Email();

        foreach ($emails as $key => $value) {
            if (!$validator->evaluate($value)) {
                throw new Exception('Error: One of the email addresses passed was not valid.');
            }

            if (!is_numeric($key)) {
                $this->emails[] = array(
                    'name'  => $key,
                    'email' => $value
                );
            } else {
                $this->emails[] = array(
                    'email' => $value
                );
            }
        }
    }

    /**
     * Method to write to the log
     *
     * @param  array $logEntry
     * @param  array $options
     * @return \Pop\Log\Writer\Mail
     */
    public function writeLog(array $logEntry, array $options = array())
    {
        $subject = (isset($options['subject'])) ?<commit_msg>Remove a dependency in Log\Writer\Mail<commit_after><?php
/**
 * Pop PHP Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.TXT.
 * It is also available through the world-wide-web at this URL:
 * http://www.popphp.org/LICENSE.TXT
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to <EMAIL> so we can send you a copy immediately.
 *
 * @category   Pop
 * @package    Pop_Log
 * @author     <NAME> <<EMAIL>>
 * @copyright  Copyright (c) 2009-2012 Moc 10 Media, LLC. (http://www.moc10media.com)
 * @license    http://www.popphp.org/LICENSE.TXT     New BSD License
 */

/**
 * @namespace
 */
namespace Pop\Log\Writer;

use Pop\Mail\Mail as PopMail;

/**
 * This is the Db writer class for the Log component.
 *
 * @category   Pop
 * @package    Pop_Log
 * @author     <NAME> <<EMAIL>>
 * @copyright  Copyright (c) 2009-2012 Moc 10 Media, LLC. (http://www.moc10media.com)
 * @license    http://www.popphp.org/LICENSE.TXT     New BSD License
 * @version    1.1.0
 */
class Mail implements WriterInterface
{

    /**
     * Array of emails in which to send the log messages
     * @var array
     */
    protected $emails = array();

    /**
     * Constructor
     *
     * Instantiate the Mail writer object.
     *
     * @param  array $emails
     * @throws Exception
     * @return \Pop\Log\Writer\Mail
     */
    public function __construct(array $emails)
    {
        if (count($emails) == 0) {
            throw new Exception('Error: There must be at least one email address passed.');
        }

        foreach ($emails as $key => $value) {
            if (!preg_match('/[a-zA-Z0-9\.\-\_+%]+@[a-zA-Z0-9\-\_\.]+\.[a-zA-Z]{2,4}/', $value)) {
                throw new Exception('Error: One of the email addresses passed was not valid.');
            }

            if (!is_numeric($key)) {
                $this->emails[] = array(
                    'name'  => $key,
                    'email' => $value
                );
            } else {
                $this->emails[] = array(
                    'email' => $value
                );
            }
        }
    }

    /**
     * Method to write to the log
     *
     * @param  array $logEntry
     * @param  array $options
     * @return \Pop\Log\Writer\Mail
     */
    public function writeLog(array $logEntry, array $options = array())
    {
        $subject = (isset($options['subject'])) ?
{'fraction_non_alphanumeric': 0.12902588421260622, 'fraction_numerical': 0.012250543370875321, 'mean_word_length': 1.9396051103368177, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 10, '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': '3428999', 'n_tokens_mistral': 1570, 'n_tokens_neox': 1503, 'n_words': 483}