All Unit tests
Current file: C:\code\midiparser\src\Midi\Event\ChannelEvent.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% 7 / 7
100.00%100.00%
100.00% 18 / 18
 
Midi\ChannelEvent
100.00%100.00%
100.00% 1 / 1
100.00%100.00%
100.00% 7 / 7
100.00%100.00%
100.00% 18 / 18
 public function __construct($channel, $param1, $param2 = null, $isContinuation = false)
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% 1 / 1
 public function toBinary()
100.00%100.00%
100.00% 1 / 1
100.00%100.00%
100.00% 3 / 3
 public function getData()
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 setContinuation($isContinuation)
100.00%100.00%
100.00% 1 / 1
100.00%100.00%
100.00% 2 / 2
 public function isContinuation()
100.00%100.00%
100.00% 1 / 1
100.00%100.00%
100.00% 1 / 1


       1                 : <?php                                                                                                                               
       2                 :                                                                                                                                     
       3                 :     /**                                                                                                                             
       4                 :      * \Midi\Event\ChannelEvent                                                                                                     
       5                 :      *                                                                                                                              
       6                 :      * @package    Midi                                                                                                             
       7                 :      * @subpackage Event                                                                                                            
       8                 :      * @copyright  © 2009 Tommy Montgomery <http://phpmidiparser.com/>                                                              
       9                 :      * @since      1.0                                                                                                              
      10                 :      */                                                                                                                             
      11                 :                                                                                                                                     
      12                 :     namespace Midi\Event;                                                                                                           
      13                 :                                                                                                                                     
      14                 :     use \Midi\Event;                                                                                                                
      15                 :     use \Midi\Util\Util;                                                                                                            
      16                 :                                                                                                                                     
      17                 :     /**                                                                                                                             
      18                 :      * Represents events that are associated with a channel                                                                         
      19                 :      *                                                                                                                              
      20                 :      * @package    Midi                                                                                                             
      21                 :      * @subpackage Event                                                                                                            
      22                 :      * @since      1.0                                                                                                              
      23                 :      */                                                                                                                             
      24               1 :     abstract class ChannelEvent implements Event, Parameterized {                                                                   
      25                 :                                                                                                                                     
      26                 :         /**                                                                                                                         
      27                 :          * The channel this event is associated with (0-15)                                                                         
      28                 :          *                                                                                                                          
      29                 :          * @var int                                                                                                                 
      30                 :          */                                                                                                                         
      31                 :         protected $channel;                                                                                                         
      32                 :                                                                                                                                     
      33                 :         /**                                                                                                                         
      34                 :          * @var int                                                                                                                 
      35                 :          */                                                                                                                         
      36                 :         protected $param1;                                                                                                          
      37                 :                                                                                                                                     
      38                 :         /**                                                                                                                         
      39                 :          * @var int                                                                                                                 
      40                 :          */                                                                                                                         
      41                 :         protected $param2;                                                                                                          
      42                 :                                                                                                                                     
      43                 :         /**                                                                                                                         
      44                 :          * @var bool                                                                                                                
      45                 :          */                                                                                                                         
      46                 :         private $isContinuation;                                                                                                    
      47                 :                                                                                                                                     
      48                 :         /**                                                                                                                         
      49                 :          * Constructor                                                                                                              
      50                 :          *                                                                                                                          
      51                 :          * @since 1.0                                                                                                               
      52                 :          *                                                                                                                          
      53                 :          * @param  int  $channel        4-bit integer                                                                               
      54                 :          * @param  int  $param1         8-bit integer                                                                               
      55                 :          * @param  int  $param2         8-bit integer                                                                               
      56                 :          * @param  bool $isContinuation                                                                                             
      57                 :          */                                                                                                                         
      58                 :         public function __construct($channel, $param1, $param2 = null, $isContinuation = false) {                                   
      59              22 :             $this->channel        = $channel;                                                                                       
      60              22 :             $this->param1         = $param1;                                                                                        
      61              22 :             $this->param2         = $param2;                                                                                        
      62              22 :             $this->isContinuation = $isContinuation;                                                                                
      63              22 :         }                                                                                                                           
      64                 :                                                                                                                                     
      65                 :         /**                                                                                                                         
      66                 :          * Gets a string representation of this event                                                                               
      67                 :          *                                                                                                                          
      68                 :          * @since 1.0                                                                                                               
      69                 :          * @uses    EventType::getEventName()                                                                                       
      70                 :          * @uses    getType()                                                                                                       
      71                 :          * @uses    getParamDescription()                                                                                           
      72                 :          *                                                                                                                          
      73                 :          * @return string                                                                                                           
      74                 :          */                                                                                                                         
      75                 :         public function __toString() {                                                                                              
      76               1 :             return EventType::getEventName($this->getType()) . ' (channel ' . $this->channel . '): ' . $this->getParamDescription();
      77                 :         }                                                                                                                           
      78                 :                                                                                                                                     
      79                 :         /**                                                                                                                         
      80                 :          * Gets a binary representation of this event                                                                               
      81                 :          *                                                                                                                          
      82                 :          * @since 1.0                                                                                                               
      83                 :          * @uses  Util::pack()                                                                                                      
      84                 :          *                                                                                                                          
      85                 :          * @return binary                                                                                                           
      86                 :          */                                                                                                                         
      87                 :         public function toBinary() {                                                                                                
      88               1 :             $binary = ($this->isContinuation()) ? '' : Util::pack($this->getType() | $this->channel);                               
      89               1 :             $binary .= Util::pack($this->param1, $this->param2);                                                                    
      90               1 :             return $binary;                                                                                                         
      91                 :         }                                                                                                                           
      92                 :                                                                                                                                     
      93                 :         /**                                                                                                                         
      94                 :          * Gets the data associated with this event                                                                                 
      95                 :          *                                                                                                                          
      96                 :          * @since 1.0                                                                                                               
      97                 :          *                                                                                                                          
      98                 :          * @return array [0] => channel, [1] => param1, [2] => param2                                                               
      99                 :          */                                                                                                                         
     100                 :         public function getData() {                                                                                                 
     101                 :             return array(                                                                                                           
     102               1 :                 $this->channel,                                                                                                     
     103               1 :                 $this->param1,                                                                                                      
     104               1 :                 $this->param2                                                                                                       
     105               1 :             );                                                                                                                      
     106                 :         }                                                                                                                           
     107                 :                                                                                                                                     
     108                 :         /**                                                                                                                         
     109                 :          * Gets the length of this event in bytes                                                                                   
     110                 :          *                                                                                                                          
     111                 :          * @since 1.0                                                                                                               
     112                 :          *                                                                                                                          
     113                 :          * @return int                                                                                                              
     114                 :          */                                                                                                                         
     115                 :         public function getLength() {                                                                                               
     116               1 :             return ($this->isContinuation) ? 2 : 3;                                                                                 
     117                 :         }                                                                                                                           
     118                 :                                                                                                                                     
     119                 :         /**                                                                                                                         
     120                 :          * Sets whether this event is a continuation event                                                                          
     121                 :          *                                                                                                                          
     122                 :          * @since 1.0                                                                                                               
     123                 :          *                                                                                                                          
     124                 :          * @param  bool $isContinuation                                                                                             
     125                 :          * @return bool                                                                                                             
     126                 :          */                                                                                                                         
     127                 :         public function setContinuation($isContinuation) {                                                                          
     128               1 :             $this->isContinuation = (bool)$isContinuation;                                                                          
     129               1 :         }                                                                                                                           
     130                 :                                                                                                                                     
     131                 :         /**                                                                                                                         
     132                 :          * Gets whether this event is a continuation event                                                                          
     133                 :          *                                                                                                                          
     134                 :          * @since 1.0                                                                                                               
     135                 :          *                                                                                                                          
     136                 :          * @return bool                                                                                                             
     137                 :          */                                                                                                                         
     138                 :         public function isContinuation() {                                                                                          
     139               2 :             return $this->isContinuation;                                                                                           
     140                 :         }                                                                                                                           
     141                 :                                                                                                                                     
     142                 :     }                                                                                                                               
     143                 :                                                                                                                                     

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.