<commit_before><?php namespace Walisph\Merchant\Brochure;

use DOMPDF;
use Exception;
use Illuminate\Config\Repository as IlluminateConfig;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Http\Response;
use Illuminate\View\Factory as IlluminateView;

class Brochure {

	/**
	 * @var IlluminateConfig
	 */
	protected $config;

	/**
	 * @var Filesystem
	 */
	protected $filesystem;

	/**
	 * @var IlluminateView
	 */
	protected $view;

	protected $public_path;
	protected $warnings, $paper, $orientation;

	/**
	 * @var DOMPDF
	 */
	protected $dompdf;


	/**
	 * @param DOMPDF $dompdf
	 * @param IlluminateConfig $config
	 * @param Filesystem $filesystem
	 * @param IlluminateView $view
	 * @param $public_path
	 */
	public function __construct( DOMPDF $dompdf, IlluminateConfig $config, Filesystem $filesystem, IlluminateView $view, $public_path )
	{
		$this->config = $config;
		$this->filesystem = $filesystem;
		$this->view = $view;
		$this->public_path = $public_path;
		$this->warnings = $this->config->get( 'walis-merchant::dompdf.show_warnings', false );
		$this->paper = $this->config->get( 'walis-merchant::dompdf.defines.DOMPDF_DEFAULT_PAPER_SIZE' );
		$this->orientation = $this->config->get( 'walis-merchant::orientation' ) ?: 'portrait';
		$this->dompdf = $dompdf;

		$this->dompdf->set_base_path( realpath( $public_path ) );
	}

	/**
	 * @return DOMPDF
	 */
	public function getDompdf()
	{
		return $this->dompdf;
	}

	/**
	 * @return mixed
	 */
	public function getPaper()
	{
		return $this->paper;
	}

	/**
	 * @param mixed $paper
	 * @param null $orientation
	 *
	 * @return $this
	 */
	public function setPaper( $paper, $orientation = null )
	{
		$this->paper = $paper;
		if ( $orientation )
		{
			$this->orientation = $orientation;
		}

		return $this;
	}

	/**
	 * @param string $orientation
	 *
	 * @return $this
	 */
	public function setOrientation( $orientation )
	{
		$this->orientation = $orientation;

		return $this;
	}

	/**
	 * @param mixed $warnings
	 *
	 * @return $this
	 */
	public function setWarnings( $warnings )
	{
		$this->warnings = $warnings;

		return $this;
	}

	public function loadHTML( $string, $encoding = null )
	{
		$string = $this->convertEntities( $string );
		$this->dompdf->load_html( $string, $encoding );
		$this->rendered = false;

		return $this;
	}

	public function loadFile( $file )
	{
		$this->dompdf->load_html_file( $file );
		$this->rendered = false;

		return $this;
	}

	public function loadView( $view, $data = [], $mergeData = [], $encoding = null )
	{
		$html = $this->view->make( $view, $data, $mergeData )->render();

		return $this->loadHTML( $html, $encoding );
	}

	public function output()
	{
		if ( ! $this->rendered )
		{
			$this->render();
		}

		return $this->dompdf->output();<commit_msg>For the mean time, comment convertEntities<commit_after><?php namespace Walisph\Merchant\Brochure;

use DOMPDF;
use Exception;
use Illuminate\Config\Repository as IlluminateConfig;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Http\Response;
use Illuminate\View\Factory as IlluminateView;

class Brochure {

	/**
	 * @var IlluminateConfig
	 */
	protected $config;

	/**
	 * @var Filesystem
	 */
	protected $filesystem;

	/**
	 * @var IlluminateView
	 */
	protected $view;

	protected $public_path;
	protected $warnings, $paper, $orientation;

	/**
	 * @var DOMPDF
	 */
	protected $dompdf;


	/**
	 * @param DOMPDF $dompdf
	 * @param IlluminateConfig $config
	 * @param Filesystem $filesystem
	 * @param IlluminateView $view
	 * @param $public_path
	 */
	public function __construct( DOMPDF $dompdf, IlluminateConfig $config, Filesystem $filesystem, IlluminateView $view, $public_path )
	{
		$this->config = $config;
		$this->filesystem = $filesystem;
		$this->view = $view;
		$this->public_path = $public_path;
		$this->warnings = $this->config->get( 'walis-merchant::dompdf.show_warnings', false );
		$this->paper = $this->config->get( 'walis-merchant::dompdf.defines.DOMPDF_DEFAULT_PAPER_SIZE' );
		$this->orientation = $this->config->get( 'walis-merchant::orientation' ) ?: 'portrait';
		$this->dompdf = $dompdf;

		$this->dompdf->set_base_path( realpath( $public_path ) );
	}

	/**
	 * @return DOMPDF
	 */
	public function getDompdf()
	{
		return $this->dompdf;
	}

	/**
	 * @return mixed
	 */
	public function getPaper()
	{
		return $this->paper;
	}

	/**
	 * @param mixed $paper
	 * @param null $orientation
	 *
	 * @return $this
	 */
	public function setPaper( $paper, $orientation = null )
	{
		$this->paper = $paper;
		if ( $orientation )
		{
			$this->orientation = $orientation;
		}

		return $this;
	}

	/**
	 * @param string $orientation
	 *
	 * @return $this
	 */
	public function setOrientation( $orientation )
	{
		$this->orientation = $orientation;

		return $this;
	}

	/**
	 * @param mixed $warnings
	 *
	 * @return $this
	 */
	public function setWarnings( $warnings )
	{
		$this->warnings = $warnings;

		return $this;
	}

	public function loadHTML( $string, $encoding = null )
	{
		//$string = $this->convertEntities( $string );
		$this->dompdf->load_html( $string, $encoding );
		$this->rendered = false;

		return $this;
	}

	public function loadFile( $file )
	{
		$this->dompdf->load_html_file( $file );
		$this->rendered = false;

		return $this;
	}

	public function loadView( $view, $data = [], $mergeData = [], $encoding = null )
	{
		$html = $this->view->make( $view, $data, $mergeData )->render();

		return $this->loadHTML( $html, $encoding );
	}

	public function output()
	{
		if ( ! $this->rendered )
		{
			$this->render();
		}

		return $this->dompdf->output();
{'fraction_non_alphanumeric': 0.1615563923256231, 'fraction_numerical': 0.0, 'mean_word_length': 3.6638795986622075, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 77, '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': '6804427', 'n_tokens_mistral': 2095, 'n_tokens_neox': 1917, 'n_words': 418}