<commit_before><?php
/**
 *  Class Visual composer Generator
 *  This class was created to generate shortcodes of visual composer plugin,
 *  to be used in templates of custom pages wordpress
 * @author <NAME> <<EMAIL>>
 * @link https://github.com/leandrogoncalves/vcgen
 * @version 1.0
 *
 */

namespace leandrogoncalves;

use leandrogoncalves\exceptions\NullException;
use leandrogoncalves\exceptions\ParameterException;

class Vcgen_core{

    /**
     * Tipos de nós
     * TYPE_NODE 1 => shortcode tag do visual composer
     */
    const TYPE_NODE = 1;

    /**
     * Nome da tag
     * @var null
     */
    protected $nodeName;

    /**
     * Valor String da Tag
     * @var null
     */
    protected $nodeValue;

    /**
     * Atributos da tag
     * @var array
     */
    protected $attributes;

    /**
     * Tag pai
     * @var array
     */
    protected $parentNode;

    /** Tag filha
     * @var array
     */
    protected $childNodes;

    /**
     * Vcgen constructor.
     */
    public function __construct() {
        $this->nodeName = null;
        $this->nodeValue = null;
        $this->attributes = [];
        $this->parentNode = [];
        $this->childNodes = [];
    }

    /**
     * Cria um novo VC shortcode
     * @param String $name
     * @param array $attributes
     * @return Vcgen
     */
    private function createElement($name, $attributes = []){
        $tmp = new self();

        try{

            if(is_array($name)) throw new ParameterException("O nome deve ser uma string", 003);
            if(empty($attributes) && !is_array($attributes))  throw new NullException("O parametro nao pode ser nulo.  ", 001);

            $tmp->nodeName = $name;
            $tmp->attributes = array_merge($tmp->attributes, $attributes);

        }catch (ParameterException $e){
            //TODO tratar mensagem
            die($e->getMessage());
        }catch (NullException $e){
            //TODO tratar mensagem
            die($e->getMessage());
        }

        return $tmp;
    }

    public function setAttr($name, $value){
        if(!in_array($name, $this->attributes)){
            $this->attributes[$name] = null;
        }

        if(!is_array($value)){
            $this->attributes[$name] = $value;
        }

        return $this;
    }


    /**
     * Cria um novo VC shortcode a partir de metodos dinamicos
     * @param $name
     * @param $attributes
     * @return Vcgen
     */
    public function __call($name, $attributes){
        try
        {
            if(empty($attributes) && !is_array($attributes))  throw new NullException("O parametro nao pode ser nulo.  ", 001);

            if(!isset($atributes['name'])) throw new NullException("O atributo nome deve ser declarado. ", 002);

            return $this->createElement($atributes['name'], $attributes);
        }catch(NullException $n){
            //TODO tratar mensagem
            die($n->getMessage());
        }
    }


}<commit_msg>split vcgen core<commit_after><?php
/**
 *  Class Visual composer Generator
 *  This class was created to generate shortcodes of visual composer plugin,
 *  to be used in templates of custom pages wordpress
 * @author <NAME> <<EMAIL>>
 * @link https://github.com/leandrogoncalves/vcgen
 * @version 1.0
 *
 */

namespace leandrogoncalves;

use leandrogoncalves\exceptions\NullException;
use leandrogoncalves\exceptions\ParameterException;

class Vcgen_core{

    /**
     * Tipos de nós
     * TYPE_NODE 1 => shortcode tag do visual composer
     */
    const TYPE_NODE = 1;

    /**
     * Nome da tag
     * @var null
     */
    protected $nodeName;

    /**
     * Valor String da Tag
     * @var null
     */
    protected $nodeValue;

    /**
     * Atributos da tag
     * @var array
     */
    protected $attributes;

    /**
     * Tag pai
     * @var array
     */
    protected $parentNode;

    /** Tag filha
     * @var array
     */
    protected $childNodes;

    /**
     * Vcgen constructor.
     */
    protected function __construct() {
        $this->nodeName = null;
        $this->nodeValue = null;
        $this->attributes = [];
        $this->parentNode = [];
        $this->childNodes = [];
    }

    /**
     * Cria um novo VC shortcode
     * @param String $name
     * @param array $attributes
     * @return Vcgen
     */
    protected function createElement($name, $attributes = []){
        $tmp = new self();

        try{

            if(is_array($name)) throw new ParameterException("O nome deve ser uma string", 003);
            if(empty($attributes) && !is_array($attributes))  throw new NullException("O parametro nao pode ser nulo.  ", 001);

            $tmp->nodeName = $name;
            $tmp->attributes = array_merge($tmp->attributes, $attributes);

        }catch (ParameterException $e){
            //TODO tratar mensagem
            die($e->getMessage());
        }catch (NullException $e){
            //TODO tratar mensagem
            die($e->getMessage());
        }

        return $tmp;
    }

    protected function setAttr($name, $value){
        if(!in_array($name, $this->attributes)){
            $this->attributes[$name] = null;
        }

        if(!is_array($value)){
            $this->attributes[$name] = $value;
        }

        return $this;
    }


    /**
     * Cria um novo VC shortcode a partir de metodos dinamicos
     * @param $name
     * @param $attributes
     * @return Vcgen
     */
    protected function __call($name, $attributes){
        try
        {
            if(empty($attributes) && !is_array($attributes))  throw new NullException("O parametro nao pode ser nulo.  ", 001);

            if(!isset($atributes['name'])) throw new NullException("O atributo nome deve ser declarado. ", 002);

            return $this->createElement($atributes['name'], $attributes);
        }catch(NullException $n){
            //TODO tratar mensagem
            die($n->getMessage());
        }
    }


}
{'fraction_non_alphanumeric': 0.1301715438950555, 'fraction_numerical': 0.0053817692566431215, 'mean_word_length': 2.0388349514563107, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 41, 'https://': 2, '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': '2596896', 'n_tokens_mistral': 1797, 'n_tokens_neox': 1725, 'n_words': 454}