EasyXmlGeneratorDriver.php
Current file: C:\DATA\Viktor\Diplomka\XSLT-Benchmarking/XSLTBenchmarking/TestsGenerator/XmlGenerator/EasyXmlGeneratorDriver.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
0.00% 0 / 1
50.00% 1 / 2 CRAP
90.91% 10 / 11
EasyXmlGeneratorDriver
0.00% 0 / 1
50.00% 1 / 2 4.01
90.91% 10 / 11
 __construct($tmpDirectory)
0.00% 0 / 1 2
0.00% 0 / 1
 generate($outputPath, $templateDir, array $settings)
100.00% 1 / 1 3
100.00% 10 / 10



       1                 : <?php                                                                                       
       2                 :                                                                                             
       3                 : /**                                                                                         
       4                 :  * XSLT Benchmarking                                                                        
       5                 :  * @link https://github.com/masicek/XSLT-Benchmarking                                       
       6                 :  * @author Viktor Mašíček <viktor@masicek.net>                                           
       7                 :  * @license "New" BSD License                                                               
       8                 :  */                                                                                         
       9                 :                                                                                             
      10                 : namespace XSLTBenchmarking\TestsGenerator;                                                  
      11                 :                                                                                             
      12                 : require_once __DIR__ . '/IXmlGeneratorDriver.php';                                          
      13                 :                                                                                             
      14                 : /**                                                                                         
      15                 :  * Driver for generating XML files by \SimpleXMLElement.                                    
      16                 :  * Generate only list of elements by settings.                                              
      17                 :  *                                                                                          
      18                 :  * @author Viktor Mašíček <viktor@masicek.net>                                           
      19                 :  */                                                                                         
      20                 : class EasyXmlGeneratorDriver implements IXmlGeneratorDriver                                 
      21                 : {                                                                                           
      22                 :                                                                                             
      23                 :                                                                                             
      24                 :     /**                                                                                     
      25                 :      * Object configuration                                                                 
      26                 :      *                                                                                      
      27                 :      * @param string $tmpDirectory The path of the temporary directory                      
      28                 :      */                                                                                     
      29                 :     public function __construct($tmpDirectory)                                              
      30                 :     {                                                                                       
      31               0 :     }                                                                                       
      32                 :                                                                                             
      33                 :                                                                                             
      34                 :     /**                                                                                     
      35                 :      * Generate xml file                                                                    
      36                 :      *                                                                                      
      37                 :      * @param string $outputPath The path of the output xml file                            
      38                 :      * @param array $settings The list of settings specific by selected xml generator       
      39                 :      *                                                                                      
      40                 :      * @return void                                                                         
      41                 :      */                                                                                     
      42                 :     public function generate($outputPath, $templateDir, array $settings)                    
      43                 :     {                                                                                       
      44               1 :         $xml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><root></root>');
      45                 :                                                                                             
      46               1 :         foreach ($settings as $elementName => $count)                                       
      47                 :         {                                                                                   
      48               1 :             for ($elementIdx = 1; $elementIdx <= $count; $elementIdx++)                     
      49                 :             {                                                                               
      50               1 :                 $xml->addChild($elementName, 'Easy element ' . $elementIdx);                
      51               1 :             }                                                                               
      52               1 :         }                                                                                   
      53                 :                                                                                             
      54                 :         // make indent and new lines                                                        
      55               1 :         $dom = dom_import_simplexml($xml)->ownerDocument;                                   
      56               1 :         $dom->formatOutput = TRUE;                                                          
      57               1 :         $dom->save($outputPath);                                                            
      58               1 :     }                                                                                       
      59                 :                                                                                             
      60                 :                                                                                             
      61                 : }                                                                                           


Generated by PHP_CodeCoverage @package_version@ using PHP 5.3.6 and PHPUnit @package_version@ at Tue Jun 26 15:06:55 CEST 2012.