FluentDOM Package
Current file: /fluentdom/releases/release_2.0/FluentDOM/Loader/FileHTML.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
100.00%100.00%
100.00% 1 / 1
100.00%100.00%
100.00% 1 / 1
100.00%100.00%
100.00% 13 / 13
 
FluentDOMLoaderFileHTML
100.00%100.00%
100.00% 1 / 1
100.00%100.00%
100.00% 1 / 1
100.00%100.00%
100.00% 13 / 13
 public function load($source, $contentType)
100.00%100.00%
100.00% 1 / 1
100.00%100.00%
100.00% 13 / 13


       1                 : <?php                                                                        
       2                 : /**                                                                          
       3                 : * Load FluentDOM from HTML file                                              
       4                 : *                                                                            
       5                 : * @version $Id: FileHTML.php 305 2009-07-24 18:03:59Z subjective $           
       6                 : * @license http://www.opensource.org/licenses/mit-license.php The MIT License
       7                 : * @copyright Copyright (c) 2009 Bastian Feder, Thomas Weinert                
       8                 : *                                                                            
       9                 : * @package FluentDOM                                                         
      10                 : * @subpackage Loaders                                                        
      11                 : */                                                                           
      12                 :                                                                              
      13                 : /**                                                                          
      14                 : * include interface                                                          
      15                 : */                                                                           
      16                 : require_once dirname(__FILE__).'/../FluentDOMLoader.php';                    
      17                 :                                                                              
      18                 : /**                                                                          
      19                 : * Load FluentDOM from HTML file                                              
      20                 : *                                                                            
      21                 : * @package FluentDOM                                                         
      22                 : * @subpackage Loaders                                                        
      23                 : */                                                                           
      24                 : class FluentDOMLoaderFileHTML implements FluentDOMLoader {                   
      25                 :                                                                              
      26                 :   /**                                                                        
      27                 :   * load DOMDocument from html file                                          
      28                 :   *                                                                          
      29                 :   * @param string $source filename                                           
      30                 :   * @param string $contentType                                               
      31                 :   * @access public                                                           
      32                 :   * @return object DOMDocument | FALSE                                       
      33                 :   */                                                                         
      34                 :   public function load($source, $contentType) {                              
      35               4 :     if (is_string($source) &&                                                
      36               3 :         FALSE === strpos($source, '<') &&                                    
      37               4 :         $contentType == 'text/html') {                                       
      38                 :                                                                              
      39               2 :       if (!file_exists($source)) {                                           
      40               1 :         throw new InvalidArgumentException('File not found: '. $source);     
      41                 :       }                                                                      
      42                 :                                                                              
      43               1 :       $dom = new DOMDocument();                                              
      44               1 :       $errorSetting = libxml_use_internal_errors(TRUE);                      
      45               1 :       libxml_clear_errors();                                                 
      46               1 :       $dom->loadHTMLFile($source);                                           
      47               1 :       libxml_clear_errors();                                                 
      48               1 :       libxml_use_internal_errors($errorSetting);                             
      49               1 :       return $dom;                                                           
      50                 :     }                                                                        
      51               2 :     return FALSE;                                                            
      52                 :   }                                                                          
      53                 : }                                                                            
      54                 :                                                                              

Generated by PHPUnit 3.3.17 and Xdebug 2.0.4 at Sat Jul 25 13:10:02 CEST 2009.