<commit_before><?php

namespace Openbuildings\Swiftmailer;

use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;
use Swift_Events_SendListener;
use Swift_Events_SendEvent;

/**
 * @package    openbuildings\swiftmailer-css-inliner
 * @author     <NAME> <<EMAIL>>
 * @copyright  (c) 2013 OpenBuildings Ltd.
 * @license    http://spdx.org/licenses/BSD-3-Clause
 */
class CssInlinerPlugin implements Swift_Events_SendListener
{
	/**
	 * @var CssToInlineStyles
	 */
	private $converter;

	/**
	 * @param CssToInlineStyles $converter
	 */
	public function __construct(CssToInlineStyles $converter = null)
	{
		if ($converter) {
			$this->converter = $converter;
		} else {
			$this->converter = new CssToInlineStyles();
			$this->converter->setUseInlineStylesBlock(true);
		}
	}

	/**
	 * @param Swift_Events_SendEvent $event
	 */
	public function beforeSendPerformed(Swift_Events_SendEvent $event)
	{
		$message = $event->getMessage();

		$this->converter->setEncoding($message->getCharset());

		if ($message->getContentType() === 'text/html') {
			$this->converter->setCSS('');
			$this->converter->setHTML($message->getBody());

			$message->setBody($this->converter->convert());
		}<commit_msg>remove deprecated call to setEncoding<commit_after><?php

namespace Openbuildings\Swiftmailer;

use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;
use Swift_Events_SendListener;
use Swift_Events_SendEvent;

/**
 * @package    openbuildings\swiftmailer-css-inliner
 * @author     <NAME> <<EMAIL>>
 * @copyright  (c) 2013 OpenBuildings Ltd.
 * @license    http://spdx.org/licenses/BSD-3-Clause
 */
class CssInlinerPlugin implements Swift_Events_SendListener
{
	/**
	 * @var CssToInlineStyles
	 */
	private $converter;

	/**
	 * @param CssToInlineStyles $converter
	 */
	public function __construct(CssToInlineStyles $converter = null)
	{
		if ($converter) {
			$this->converter = $converter;
		} else {
			$this->converter = new CssToInlineStyles();
			$this->converter->setUseInlineStylesBlock(true);
		}
	}

	/**
	 * @param Swift_Events_SendEvent $event
	 */
	public function beforeSendPerformed(Swift_Events_SendEvent $event)
	{
		$message = $event->getMessage();

		if ($message->getContentType() === 'text/html') {
			$this->converter->setCSS('');
			$this->converter->setHTML($message->getBody());

			$message->setBody($this->converter->convert());
		}
{'fraction_non_alphanumeric': 0.14825828377230246, 'fraction_numerical': 0.004248088360237893, 'mean_word_length': 4.688405797101449, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 40, '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': '323659', 'n_tokens_mistral': 862, 'n_tokens_neox': 807, 'n_words': 127}