Current file: /Users/bill/git/HTTP_OAuth/HTTP/OAuth/Signature/Common.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% 3 / 3 CRAP
100.00%100.00%
100.00% 13 / 13
 
HTTP_OAuth_Signature_Common
100.00%100.00%
100.00% 1 / 1
100.00%100.00%
100.00% 3 / 3
100.00%100.00%
100.00% 13 / 13
 getBase($method, $url, array $params)
100.00%100.00%
100.00% 1 / 1 2
100.00%100.00%
100.00% 9 / 9
 getKey($consumerSecret, $tokenSecret = '')
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 4 / 4
 build($method, $url, array $params, $consumerSecret, $tokenSecret = '' )
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 0 / 0


       1                 : <?php                                                                           
       2                 : /**                                                                             
       3                 :  * HTTP_OAuth                                                                   
       4                 :  *                                                                              
       5                 :  * Implementation of the OAuth specification                                    
       6                 :  *                                                                              
       7                 :  * PHP version 5.2.0+                                                           
       8                 :  *                                                                              
       9                 :  * LICENSE: This source file is subject to the New BSD license that is          
      10                 :  * available through the world-wide-web at the following URI:                   
      11                 :  * http://www.opensource.org/licenses/bsd-license.php. If you did not receive   
      12                 :  * a copy of the New BSD License and are unable to obtain it through the web,   
      13                 :  * please send a note to license@php.net so we can mail you a copy immediately. 
      14                 :  *                                                                              
      15                 :  * @category  HTTP                                                              
      16                 :  * @package   HTTP_OAuth                                                        
      17                 :  * @author    Jeff Hodsdon <jeffhodsdon@gmail.com>                              
      18                 :  * @copyright 2009 Jeff Hodsdon <jeffhodsdon@gmail.com>                         
      19                 :  * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
      20                 :  * @link      http://pear.php.net/package/HTTP_OAuth                            
      21                 :  * @link      http://github.com/jeffhodsdon/HTTP_OAuth                          
      22                 :  */                                                                             
      23                 :                                                                                 
      24                 : require_once 'HTTP/OAuth.php';                                                  
      25                 :                                                                                 
      26                 : /**                                                                             
      27                 :  * HTTP_OAuth_Signature_Common                                                  
      28                 :  *                                                                              
      29                 :  * Common class for signature implemenations. Holds specification logic to      
      30                 :  * create signature base strings and keys.                                      
      31                 :  *                                                                              
      32                 :  * @category  HTTP                                                              
      33                 :  * @package   HTTP_OAuth                                                        
      34                 :  * @author    Jeff Hodsdon <jeffhodsdon@gmail.com>                              
      35                 :  * @copyright 2009 Jeff Hodsdon <jeffhodsdon@gmail.com>                         
      36                 :  * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
      37                 :  * @link      http://pear.php.net/package/HTTP_OAuth                            
      38                 :  * @link      http://github.com/jeffhodsdon/HTTP_OAuth                          
      39                 :  */                                                                             
      40                 : abstract class HTTP_OAuth_Signature_Common extends HTTP_OAuth                   
      41                 : {                                                                               
      42                 :                                                                                 
      43                 :     /**                                                                         
      44                 :      * Get base                                                                 
      45                 :      *                                                                          
      46                 :      * @param mixed $method HTTP method used in the request                     
      47                 :      * @param mixed $url    URL of the request                                  
      48                 :      * @param array $params Parameters in the request                           
      49                 :      *                                                                          
      50                 :      * @return string Base signature string                                     
      51                 :      */                                                                         
      52                 :     public function getBase($method, $url, array $params)                       
      53                 :     {                                                                           
      54               6 :         if (array_key_exists('oauth_signature', $params)) {                     
      55               2 :             unset($params['oauth_signature']);                                  
      56               2 :         }                                                                       
      57                 :                                                                                         
      58               6 :         $croppedUrl = reset(explode('?', $url));                                
      59                 :                                                                                         
      60               6 :         $parts = array($method, $croppedUrl,                                    
      61               6 :             HTTP_OAuth::buildHTTPQuery($params));                               
      62               6 :         $base  = implode('&', HTTP_OAuth::urlencode($parts));                   
      63               6 :         $this->debug('Signing with base string: ' . $base);                     
      64               6 :         return $base;                                                           
      65                 :     }                                                                           
      66                 :                                                                                 
      67                 :     /**                                                                         
      68                 :      * Get key                                                                  
      69                 :      *                                                                          
      70                 :      * @param string $consumerSecret Consumer secret value                      
      71                 :      * @param string $tokenSecret    Token secret value (if exists)             
      72                 :      *                                                                          
      73                 :      * @return string Signature key                                             
      74                 :      */                                                                         
      75                 :     public function getKey($consumerSecret, $tokenSecret = '')                  
      76                 :     {                                                                           
      77               6 :         $secrets = array($consumerSecret, $tokenSecret);                        
      78               6 :         $key = implode('&', HTTP_OAuth::urlencode($secrets));                   
      79               6 :         $this->debug('Signing with key: ' . $key);                              
      80               6 :         return $key;                                                            
      81                 :     }                                                                           
      82                 :                                                                                 
      83                 :     /**                                                                         
      84                 :      * Build                                                                    
      85                 :      *                                                                          
      86                 :      * @param string $method         HTTP method used                           
      87                 :      * @param string $url            URL of the request                         
      88                 :      * @param array  $params         Parameters of the request                  
      89                 :      * @param string $consumerSecret Consumer secret value                      
      90                 :      * @param string $tokenSecret    Token secret value (if exists)             
      91                 :      *                                                                          
      92                 :      * @return string Signature                                                 
      93                 :      */                                                                         
      94                 :     abstract public function build($method, $url, array $params,                
      95                 :         $consumerSecret, $tokenSecret = ''                                      
      96                 :     );                                                                          
      97                 : }                                                                               
      98                 :                                                                                 
      99                 :                                                                                 

Generated by PHP_CodeCoverage 1.0.2 using PHP 5.3.3 and PHPUnit 3.5.6 at Tue Dec 28 21:42:13 PST 2010.