/**
  * @param String $fileType
  * @param Array $configuration
  * @return ConfigurationFile
  */
 public static function deserialize($fileType, $configuration)
 {
     $configurationFile = new ConfigurationFile($fileType);
     $leafs = self::getInstance()->explodeOnLeafs($configuration);
     $paths = self::getInstance()->explodeOnPath($leafs);
     foreach ($paths as $key => $path) {
         $fullPath = new DirectivePath($path);
         $parentPath = $fullPath->getParentPath();
         $context = $configurationFile->getContextByPath($parentPath);
         $configurationFile->addDirective($fullPath->getDirectiveType(), $fullPath->getDirectiveValue(), $context);
     }
     return $configurationFile;
 }
 /**
  * Addind directives from query in configurationFile
  * @param Array $directivesArray
  * @param ConfigurationFile $configurationFile
  * @param iContext $context
  */
 protected function processQueueOfDirectives(array &$directivesArray, ConfigurationFile $configurationFile, iContext $context)
 {
     // start process all directives
     while (count($directivesArray)) {
         // get first in stack of directives
         $plain_directive = array_shift($directivesArray);
         //process directive syntx
         // is section?
         if (substr($plain_directive, 0, 1) == "<" and substr($plain_directive, strlen($plain_directive) - 1, 1) == ">") {
             $sectionDirective = true;
             // is end of section?
             if (substr($plain_directive, 0, 2) == "</") {
                 $endOfSection = true;
             } else {
                 $endOfSection = false;
                 // cut section delimeters
                 $plain_directive = substr($plain_directive, 1, strlen($plain_directive) - 2);
             }
         } else {
             $sectionDirective = false;
             $endOfSection = false;
         }
         if (!$endOfSection) {
             // parse name and value of directive
             $exploded_directive = explode(" ", $plain_directive);
             $directiveName = array_shift($exploded_directive);
             $directiveValue = implode(" ", $exploded_directive);
             $directiveValue = trim($directiveValue);
             // add directive in configurationFile
             $directive = $configurationFile->addDirective($directiveName, $directiveValue, $context);
             // if section, recursively process next directives in queue, while this section wouldn't ends
             if ($sectionDirective) {
                 $this->processQueueOfDirectives($directivesArray, $configurationFile, $directive);
             }
         } else {
             // if ends of section stop, this cycle
             break;
         }
     }
     // finaly stop process
     return;
 }