<commit_before><?php
/** @formatter:off
 * ******************************************************************
 * Created by   <NAME> on Jun 29, 2016 - 8:06:17 AM
 * Contact      <EMAIL>
 * @copyright   2016 <NAME> - https://github.com/mkungla
 * @license     The MIT License (MIT)
 * 
 * @category       AframeVR
 * @package        aframe-php
 * 
 * Lang         PHP (php version >= 7)
 * Encoding     UTF-8
 * File         AframeDOMProcessor.php
 * Code format  PSR-2 and 12
 * @link        https://github.com/mkungla/aframe-php
 ^ @issues      https://github.com/mkungla/aframe-php/issues
 * ********************************************************************
 * Contributors:
 * @author <NAME> <<EMAIL>>
 * ********************************************************************
 * Comments:
 * @formatter:on */
namespace AframeVR\Core\DOM;

trait AframeDOMProcessor
{

    /**
     * Add document comment for formatting
     *
     * @param string $element            
     * @param string $comment            
     */
    protected function appendFormatComment(string $element, string $comment)
    {
        if ($this->formatOutput) {
            $com = $this->docObj->createComment($comment);
            $this->{$element}->appendChild($com);
        }
    }

    /**
     * Correct html format for tags which are not supported by DOMDocument
     *
     * @param string $html            
     * @return string
     */
    protected function correctOutputFormat($html)
    {
        $tags = array(
            '<!--',
            '-->',
            '<a-assets>',
            '</a-assets>',
            '</a-scene>'
        );
        $values = array(
            '',
            "\t",
            "\n\t<a-assets>",
            "\n\t</a-assets>",
            "\n</a-scene>"
        );
        return str_ireplace($tags, $values, $html);
    }

    /**
     * Prepeare head
     *
     * @return void
     */
    protected function renderHead()
    {
        $title = $this->docObj->createElement('title', $this->scene_title);
        $this->head->appendChild($title);
        $this->appendDefaultMetaTags();
        $this->appendCDN();
    }

    /**
     * Append deffault metatags
     *
     * @return void
     */
    protected function appendDefaultMetaTags()
    {
        $this->appendMetaTag(array(
            'name' => 'description',
            'content' => $this->scene_description
        ));
        foreach ($this->getDefaultMetaTags() as $tag)
            $this->appendMetaTag($tag);
    }

    /**
     * Get default meta tags
     *
     * @return array
     */
    protected function getDefaultMetaTags(): array
    {
        $dmt = array();
        $dmt[0]['charset'] = 'utf-8';
        
        $dmt[1]['name'] = 'viewport';
        
        $vp = 'width=device-width,initial-scale=1,maximum-scale=1,shrink-to-fit=no,user-scalable=no,minimal-ui';
        
        $dmt[1]['content'] = $vp;
        $dmt[2]['name'] = 'mobile-web-app-capable';
        $dmt[2]['content'] = 'yes';
        $dmt[3]['name'] = 'theme-color';
        $dmt[3]['content'] = 'black';
        
        return $dmt;
    }<commit_msg>added abstract methods for AframeDOMProcessor<commit_after><?php
/** @formatter:off
 * ******************************************************************
 * Created by   <NAME> on Jun 29, 2016 - 8:06:17 AM
 * Contact      <EMAIL>
 * @copyright   2016 <NAME> - https://github.com/mkungla
 * @license     The MIT License (MIT)
 * 
 * @category       AframeVR
 * @package        aframe-php
 * 
 * Lang         PHP (php version >= 7)
 * Encoding     UTF-8
 * File         AframeDOMProcessor.php
 * Code format  PSR-2 and 12
 * @link        https://github.com/mkungla/aframe-php
 ^ @issues      https://github.com/mkungla/aframe-php/issues
 * ********************************************************************
 * Contributors:
 * @author <NAME> <<EMAIL>>
 * ********************************************************************
 * Comments:
 * @formatter:on */
namespace AframeVR\Core\DOM;

trait AframeDOMProcessor
{
    /**
     * A-Frame DOM Document type
     *
     * @var \DOMDocumentType
     */
    protected $doctypeObj;
    
    /**
     * A-Frame DOM Document
     *
     * @var \DOMDocument
     */
    protected $docObj;
    
    /**
     * Scene meta tile
     *
     * @var string $scene_title
     */
    protected $scene_title = 'Untitled';
    
    /**
     * Scene meta description
     *
     * @var string $scene_description
     */
    protected $scene_description = '';
    
    /**
     * CDN Of aframe.js
     *
     * @var string
     */
    protected $aframe_cdn;
    
    /**
     * Whether to use CDN
     *
     * @var bool $use_cdn
     */
    protected $use_cdn = false;
    
    /**
     * <head>
     *
     * @var \DOMElement
     */
    protected $head;
    
    /**
     * <a-scene>
     *
     * @var \DOMElement
     */
    protected $scene;
    
    /**
     * Nicely formats output with indentation and extra space.
     *
     * @var bool
     */
    protected $formatOutput = false;
    
    /**
     * \DOMImplementation::createDocumentType
     * 
     * DOMImplementation::createDocumentType — Creates an empty DOMDocumentType object 
     * 
     * {@inheritdoc}
     * 
     * @param string $qualifiedName
     * @param string $publicId
     * @param string $systemId
     */
    abstract protected function createDocumentType($qualifiedName, $publicId, $systemId);
    
    /**
     * \DOMImplementation::createDocument
     * 
     * {@inheritdoc}
     * 
     * @param string $namespaceURI
     * @param string $qualifiedName
     * @param \DOMDocumentType $doctype
     */
    abstract protected function createDocument($namespaceURI, $qualifiedName, \DOMDocumentType $doctype);
    
    /**
     * Add document comment for formatting
     *
     * @param string $element            
     * @param string $comment            
     */
    protected function appendFormatComment(string $element, string $comment)
    {
        if ($this->formatOutput) {
            $com = $this->docObj->createComment($comment);
            $this->{$element}->appendChild($com);
        }
    }

    /**
     * Correct html format for tags which are not supported by DOMDocument
     *
     * @param string $html            
     * @return string
     */
    protected function correctOutputFormat($html)
    {
        $tags   = array(
            '<!--',
            '-->',
            '<a-assets>',
            '</a-assets>',
            '</a-scene>'
        );
        $values = array(
            '',
            "\t",
            "\n\t<a-assets>",
            "\n\t</a-assets>",
            "\n</a-scene>"
        );
        return str_ireplace($tags, $values, $html);
    }

    /**
     * Prepeare head
     *
     * @return void
     */
    protected function renderHead()
    {
        $title = $this->docObj->createElement('title', $this->scene_title);
        $this->head->appendChild($title);
        $this->appendDefaultMetaTags();
        $this->appendCDN();
    }

    /**
     * Append deffault metatags
     *
     * @return void
     */
    protected function appendDefaultMetaTags()
    {
        $this->appendMetaTag(array(
            'name' => 'description',
            'content' => $this->scene_description
        ));
        foreach ($this->getDefaultMetaTags() as $tag)
            $this->appendMetaTag($tag);
    }

    /**
     * Get default meta tags
     *
     * @return array
     */
    protected function getDefaultMetaTags(): array
    {
        $dmt = array();
        $dmt[0]['charset'] = 'utf-8';     
        $dmt[1]['name']    = 'viewport';
        
        $vp = 'width=device-width,initial-scale=1,maximum-scale=1,shrink-to-fit=no,user-scalable=no,minimal-ui';
        
        $dmt[1]['content'] = $vp;
        $dmt[2]['name']    = 'mobile-web-app-capable';
        $dmt[2]['content'] = 'yes';
        $dmt[3]['name']    = 'theme-color';
        $dmt[3]['content'] = 'black';
        
        return $dmt;
    }
{'fraction_non_alphanumeric': 0.1911654604442226, 'fraction_numerical': 0.007486897928624906, 'mean_word_length': 1.8799856270212, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 69, 'https://': 6, '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': '2997538', 'n_tokens_mistral': 2414, 'n_tokens_neox': 2333, 'n_words': 460}