public function setPath(string $pathname) : Session
 {
     if (!$this->isStart) {
         if (is_dir($pathname)) {
             ini_set("session.save_path", $pathname);
         } else {
             Lang::addRoot(LanguagePack::PACKAGE, LanguagePack::PATH);
             throw new Exception(Lang::get("changedirective:path:notexists", "helionogueir/changedirective", array("pathname" => $pathname)));
         }
     }
     return $this;
 }
 /**
  * Read file and print
  * @param string $pathname File name to be read
  * @param bool $download Force download
  * @return null
  */
 public function read(string $pathname, bool $download = false)
 {
     $auth = false;
     if (!empty($pathname) && file_exists($pathname) && is_file($pathname)) {
         $filename = preg_replace($this->pattern, '$3', $pathname);
         $extention = preg_replace($this->pattern, '$4', $pathname);
         $this->setHeader($pathname, $filename, $extention, $download);
         ob_clean();
         flush();
         readfile($pathname);
         $auth = true;
     }
     // Exception
     if (!$auth) {
         Lang::addRoot(LanguagePack::PACKAGE, LanguagePack::PATH);
         throw new Exception(Lang::get('filecreator:upload:readfile:read', 'helionogueir/filecreator', array("pathname" => $pathname)));
     }
     return null;
 }
 /**
  * Contruct basic parameters:
  * - Get basic paramiters of match
  * 
  * @param helionogueir\typeBoxing\type\String $text Keywords of find the pattern
  * @param helionogueir\typeBoxing\type\String $value Value return case the pattern is match
  * @param helionogueir\typeBoxing\type\String $directory Path directory of pattern
  * @param helionogueir\typeBoxing\type\String $patternName Name of pattern
  * @return null
  */
 public function __construct(string $text, string $value, string $directory, string $patternName = null)
 {
     $this->text = $text;
     if ($this->text->isEmpty()) {
         Lang::addRoot(new String(\helionogueir\brainiac\autoload\LanguagePack::PACKAGE), new String(\helionogueir\brainiac\autoload\LanguagePack::PATH));
         throw new Exception(Lang::get(new String('brainiac:paramter:isnotnull'), new String('helionogueir/brainiac'), array('value' => 'text')));
     }
     $this->value = $value;
     $this->directory = $directory;
     if ($this->directory->isEmpty() || !is_dir($this->directory) || !is_readable($this->directory) || count(scandir($this->directory)) <= 2) {
         Lang::addRoot(new String(\helionogueir\brainiac\autoload\LanguagePack::PACKAGE), new String(\helionogueir\brainiac\autoload\LanguagePack::PATH));
         throw new Exception(Lang::get(new String('brainiac:paramter:isnotnull'), new String('helionogueir/brainiac'), array('value' => 'directory')));
     }
     $this->patternName = $patternName;
     if (!is_null($this->patternName) && !$this->patternName->isEmpty()) {
         if (!is_file($this->patternName) || !is_readable($this->patternName)) {
             Lang::addRoot(new String(\helionogueir\brainiac\autoload\LanguagePack::PACKAGE), new String(\helionogueir\brainiac\autoload\LanguagePack::PATH));
             throw new Exception(Lang::get(new String('brainiac:paramter:isnotnull'), new String('helionogueir/brainiac'), array('value' => 'patternName')));
         }
     }
     return null;
 }
 /**
  * Contruct pattern:
  * - Get the filename and construct the pattern
  * 
  * @param helionogueir\typeBoxing\type\String $filename Keywords of find the pattern
  * @return null
  */
 public function __construct(string $filename)
 {
     if (is_file($filename) && is_readable($filename) && preg_match('/^(.*)\\/(.*)\\.(json)$/', $filename)) {
         $decode = new Decode(file_get_contents($filename));
         $this->name = $decode->name;
         if (empty($this->name)) {
             Lang::addRoot(new String(\helionogueir\brainiac\autoload\LanguagePack::PACKAGE), new String(\helionogueir\brainiac\autoload\LanguagePack::PATH));
             throw new Exception(Lang::get(new String('brainiac:paramter:isnotnull'), new String('helionogueir/brainiac'), array('value' => 'name')));
         }
         $this->pattern = $decode->pattern;
         if (!is_array($this->pattern) || !count($this->pattern)) {
             Lang::addRoot(new String(\helionogueir\brainiac\autoload\LanguagePack::PACKAGE), new String(\helionogueir\brainiac\autoload\LanguagePack::PATH));
             throw new Exception(Lang::get(new String('brainiac:paramter:isnotnull'), new String('helionogueir/brainiac'), array('value' => 'pattern')));
         }
         $this->rule = $decode->rule;
         if ($this->rule instanceof stdClass) {
             $this->rule->clear = isset($this->rule->clear) ? $decode->rule->clear : null;
             $this->rule->space = isset($this->rule->space) ? $decode->rule->space : false;
             $this->rule->case = isset($this->rule->case) ? $decode->rule->case : null;
             $this->rule->trim = isset($this->rule->trim) ? $decode->rule->trim : false;
             $this->rule->test = isset($this->rule->test) ? $decode->rule->test : null;
             $this->rule->numeric = isset($this->rule->numeric) ? $decode->rule->numeric : false;
             $this->rule->length = isset($this->rule->length) ? $decode->rule->length : null;
             if (!isset($this->rule->lengthBetween, $this->rule->lengthBetween->min, $this->rule->lengthBetween->max)) {
                 $this->rule->lengthBetween = null;
             }
         }
         if ($decode->behavior instanceof stdClass) {
             $this->behavior = $decode->behavior;
         }
     } else {
         Lang::addRoot(new String(\helionogueir\brainiac\autoload\LanguagePack::PACKAGE), new String(\helionogueir\brainiac\autoload\LanguagePack::PATH));
         throw new Exception(Lang::get(new String('brainiac:match:filename:invalid'), new String('helionogueir/brainiac')));
     }
     return null;
 }
 /**
  * Load package:
  * - Identify and load package language;
  * 
  * @param string $package Package of language
  * @return stdClass Return package of language
  */
 private static function loadPackage(string $package)
 {
     $language = null;
     if (!empty($package)) {
         $filename = null;
         if ($packageData = explode(":", $package)) {
             if (!empty($packageData[0])) {
                 $filename .= Lang::$root[$packageData[0]];
             }
             if (!empty($packageData[1])) {
                 $filename .= DIRECTORY_SEPARATOR . $packageData[1];
             }
             $pathaname = Lang::selectPackage($filename);
             if (file_exists($pathaname)) {
                 $pathaname = Path::replaceOSSeparator($pathaname);
                 $decode = json_decode(file_get_contents((new SplFileObject($pathaname, "r"))->getPathname()));
                 $language = JSON_ERROR_NONE == json_last_error() ? $decode : null;
             }
         }
     }
     return $language;
 }
/**
 * Smarty modifier plugin
 * Type:     modifier
 * Name:     languagepack_lang
 * Purpose:  Translate the information
 * 
 * @author Helio Nogueira <*****@*****.**>
 * @param string $identify Identify of language
 * @param string $package Package of language
 * @param array $data Data repalce of language
 *
 * @return string
 */
function smarty_modifier_languagepack_lang($identify, $package, array $data = array())
{
    require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . DIRECTORY_SEPARATOR . 'autoload.php';
    return \helionogueir\languagepack\Lang::get($identify, $package, $data);
}
 /**
  * Create name:
  * - Create name of the new file
  * 
  * @param string $filename Name of file in $_FILE
  * @return string Path with name of new file
  */
 private function createFilename(string $filename)
 {
     $name = null;
     if (isset($_FILES["{$filename}"], $_FILES["{$filename}"]['name']) && preg_match($this->pattern, $_FILES["{$filename}"]['name'])) {
         $extention = preg_replace($this->pattern, '$2', $_FILES["{$filename}"]['name']);
         $name = NameGenarator::uniqueName() . ".{$extention}";
     }
     // Exception
     if (empty($name)) {
         Lang::addRoot(\helionogueir\filecreator\autoload\LanguagePack::PACKAGE, \helionogueir\filecreator\autoload\LanguagePack::PATH);
         throw new Exception(Lang::get("filecreator:upload:save:createFilename", 'filecreator'));
     }
     return $name;
 }