All Unit tests
Current file: C:\code\midiparser\src\Midi\FileHeader.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% 5 / 5
100.00%100.00%
100.00% 18 / 18
 
Midi\FileHeader
100.00%100.00%
100.00% 1 / 1
100.00%100.00%
100.00% 5 / 5
100.00%100.00%
100.00% 18 / 18
 public function __construct($midiFormat, $numTracks, $timeDivision)
100.00%100.00%
100.00% 1 / 1
100.00%100.00%
100.00% 4 / 4
 public function getLength()
100.00%100.00%
100.00% 1 / 1
100.00%100.00%
100.00% 1 / 1
 public function getData()
100.00%100.00%
100.00% 1 / 1
100.00%100.00%
100.00% 4 / 4
 public function toBinary()
100.00%100.00%
100.00% 1 / 1
100.00%100.00%
100.00% 5 / 5
 public function __toString()
100.00%100.00%
100.00% 1 / 1
100.00%100.00%
100.00% 3 / 3


       1                 : <?php                                                                                                
       2                 :                                                                                                      
       3                 :     /**                                                                                              
       4                 :      * \Midi\FileHeader                                                                              
       5                 :      *                                                                                               
       6                 :      * @package   Midi                                                                               
       7                 :      * @copyright © 2009 Tommy Montgomery <http://phpmidiparser.com>                                 
       8                 :      * @since     1.0                                                                                
       9                 :      */                                                                                              
      10                 :                                                                                                      
      11                 :     namespace Midi;                                                                                  
      12                 :                                                                                                      
      13                 :     /**                                                                                              
      14                 :      * Represents a MIDI file header                                                                 
      15                 :      *                                                                                               
      16                 :      * @package Midi                                                                                 
      17                 :      * @since   1.0                                                                                  
      18                 :      */                                                                                              
      19               1 :     class FileHeader implements Chunk {                                                              
      20                 :                                                                                                      
      21                 :         /**                                                                                          
      22                 :          * @var int                                                                                  
      23                 :          */                                                                                          
      24                 :         protected $midiFormat;                                                                       
      25                 :                                                                                                      
      26                 :         /**                                                                                          
      27                 :          * @var int                                                                                  
      28                 :          */                                                                                          
      29                 :         protected $numTracks;                                                                        
      30                 :                                                                                                      
      31                 :         /**                                                                                          
      32                 :          * @var int                                                                                  
      33                 :          */                                                                                          
      34                 :         protected $timeDivision;                                                                     
      35                 :                                                                                                      
      36                 :         /**                                                                                          
      37                 :          * The length of a MIDI file header                                                          
      38                 :          *                                                                                           
      39                 :          * @var int                                                                                  
      40                 :          */                                                                                          
      41                 :         const LENGTH = 14;                                                                           
      42                 :                                                                                                      
      43                 :         /**                                                                                          
      44                 :          * Constructor                                                                               
      45                 :          *                                                                                           
      46                 :          * @since 1.0                                                                                
      47                 :          *                                                                                           
      48                 :          * @param  int $midiFormat   The MIDI file format; valid values are 0, 1 or 2                
      49                 :          * @param  int $numTracks    The number of tracks in the MIDI file                           
      50                 :          * @param  int $timeDivision The number of clock ticks per quarter note (240 is the standard)
      51                 :          */                                                                                          
      52                 :         public function __construct($midiFormat, $numTracks, $timeDivision) {                        
      53               6 :             $this->midiFormat   = $midiFormat;                                                       
      54               6 :             $this->numTracks    = $numTracks;                                                        
      55               6 :             $this->timeDivision = $timeDivision;                                                     
      56               6 :         }                                                                                            
      57                 :                                                                                                      
      58                 :         /**                                                                                          
      59                 :          * @since 1.0                                                                                
      60                 :          *                                                                                           
      61                 :          * @return int                                                                               
      62                 :          */                                                                                          
      63                 :         public function getLength() {                                                                
      64               1 :             return self::LENGTH;                                                                     
      65                 :         }                                                                                            
      66                 :                                                                                                      
      67                 :         /**                                                                                          
      68                 :          * @since 1.0                                                                                
      69                 :          *                                                                                           
      70                 :          * @return array [0] => midi format, [1] => # of tracks, [2] => time division                
      71                 :          */                                                                                          
      72                 :         public function getData() {                                                                  
      73                 :             return array(                                                                            
      74               3 :                 $this->midiFormat,                                                                   
      75               3 :                 $this->numTracks,                                                                    
      76               3 :                 $this->timeDivision                                                                  
      77               3 :             );                                                                                       
      78                 :         }                                                                                            
      79                 :                                                                                                      
      80                 :         /**                                                                                          
      81                 :          * @since 1.0                                                                                
      82                 :          * @uses  Util::pack()                                                                       
      83                 :          *                                                                                           
      84                 :          * @return binary                                                                            
      85                 :          */                                                                                          
      86                 :         public function toBinary() {                                                                 
      87                 :             return                                                                                   
      88               1 :                 Util\Util::pack(0x4D, 0x54, 0x68, 0x64) .                                            
      89               1 :                 Util\Util::pack(0x00, 0x00, 0x00, 0x06) .                                            
      90               1 :                 Util\Util::pack(0x00, $this->midiFormat) .                                           
      91               1 :                 Util\Util::pack($this->numTracks >> 8, $this->numTracks & 0xFF) .                    
      92               1 :                 Util\Util::pack($this->timeDivision >> 8, $this->timeDivision & 0xFF);               
      93                 :         }                                                                                            
      94                 :                                                                                                      
      95                 :         /**                                                                                          
      96                 :          * @since 1.0                                                                                
      97                 :          *                                                                                           
      98                 :          * @return string                                                                            
      99                 :          */                                                                                          
     100                 :         public function __toString() {                                                               
     101                 :             return                                                                                   
     102                 :                 'MIDI file header: MIDI format ' .                                                   
     103               1 :                 $this->midiFormat . ', ' .                                                           
     104               1 :                 $this->numTracks . ' tracks, time division: ' .                                      
     105               1 :                 $this->timeDivision;                                                                 
     106                 :         }                                                                                            
     107                 :                                                                                                      
     108                 :     }                                                                                                
     109                 :                                                                                                      

Generated by PHPUnit 3.4.1 and Xdebug 2.0.5 using PHP 5.3.0 at Sun Oct 25 23:35:09 PDT 2009.