<?php
/*
 * Software Name: Eorisis Pixels
 * Software URI: https://eorisis.com/shop/software/joomla/pixels
 * Author: Eorisis
 * Author URI: https://eorisis.com
 * Copyright: Copyright (C) 2011-2025 EORISIS. All Rights Reserved.
 * License: GNU General Public License version 2; See https://eorisis.com/gpl
 * Terms of Service: https://eorisis.com/tos
 */
namespace com_eorisis_pixels\framework\lib\core\model;
\defined('_JEXEC') or die;

use com_eorisis_pixels\framework\lib\core\cms\document as cms_document;
use com_eorisis_pixels\framework\lib\core\model\metapixel as metapixel_model;
use com_eorisis_pixels\framework\lib\core\model\strip;
use com_eorisis_pixels\framework\lib\core\model\find;

class body
{
	public function __construct() {}

	// --------------------------------------------------

	public static function process() // void
	{
		$metapixel_model = new metapixel_model;
		$html = $metapixel_model->get_img();
		if ($html)
		{
			self::add_to_end("\n".$html."\n");
		}
	}

	// --------------------------------------------------

	private static function add_to_end(string $string) // void
	{
		$html = cms_document::get_body();

		$pos = find::strrpos('</body>', $html);
		if ($pos <= 0)
		{
			return;
		}

		$html = strip::substr($html, 0, $pos).$string.strip::substr($html, $pos, null);
		cms_document::set_body($html);
	}
}
