original_string: public static function getKeyUri($type, $label, $secret, $counter = null, $options = array())
      {
          // two types only..
          if (!in_array($type, self::$allowedTypes)) {
              throw new \InvalidArgumentException('Type has to be of allowed types list');
          }
  
          // Label can't be empty
          $label = trim($label);
  
          if (strlen($label) < 1) {
              throw new \InvalidArgumentException('Label has to be one or more printable characters');
          }
  
          if (substr_count($label, ':') > 2) {
          	throw new \InvalidArgumentException('Account name contains illegal colon characters');
          }
  
          // Secret needs to be here
          if (strlen($secret) < 1) {
              throw new \InvalidArgumentException('No secret present');
          }
  
          // check for counter on hotp
          if ($type == 'hotp' && is_null($counter)) {
              throw new \InvalidArgumentException('Counter required for hotp');
          }
  
          // This is the base, these are at least required
          $otpauth = 'otpauth://' . $type . '/' . rawurlencode($label) . '?secret=' . rawurlencode($secret);
  
          if ($type == 'hotp' && !is_null($counter)) {
              $otpauth .= '&counter=' . intval($counter);
          }
  
          // Now check the options array
  
          // algorithm (currently ignored by Authenticator)
          // Defaults to SHA1
          if (array_key_exists('algorithm', $options)) {
              $otpauth .= '&algorithm=' . rawurlencode($options['algorithm']);
          }
  
          // digits (currently ignored by Authenticator)
          // Defaults to 6
          if (array_key_exists('digits', $options) && intval($options['digits']) !== 6 && intval($options['digits']) !== 8) {
          	throw new \InvalidArgumentException('Digits can only have the values 6 or 8, ' . $options['digits'] . ' given');
          } elseif (array_key_exists('digits', $options)) {
              $otpauth .= '&digits=' . intval($options['digits']);
          }
  
          // period, only for totp (currently ignored by Authenticator)
          // Defaults to 30
          if ($type == 'totp' && array_key_exists('period', $options)) {
              $otpauth .= '&period=' . rawurlencode($options['period']);
          }
  
          // issuer
          // Defaults to none
          if (array_key_exists('issuer', $options)) {
              $otpauth .= '&issuer=' . rawurlencode($options['issuer']);
          }
  
          // image (to accepts images for freeotp)
          if (array_key_exists('image', $options)) {
              $otpauth .= '&image=' . $options['image'];
          }
  
          return $otpauth;
      }
code: public static function getKeyUri($type, $label, $secret, $counter = null, $options = array())
      {
          // two types only..
          if (!in_array($type, self::$allowedTypes)) {
              throw new \InvalidArgumentException('Type has to be of allowed types list');
          }
  
          // Label can't be empty
          $label = trim($label);
  
          if (strlen($label) < 1) {
              throw new \InvalidArgumentException('Label has to be one or more printable characters');
          }
  
          if (substr_count($label, ':') > 2) {
          	throw new \InvalidArgumentException('Account name contains illegal colon characters');
          }
  
          // Secret needs to be here
          if (strlen($secret) < 1) {
              throw new \InvalidArgumentException('No secret present');
          }
  
          // check for counter on hotp
          if ($type == 'hotp' && is_null($counter)) {
              throw new \InvalidArgumentException('Counter required for hotp');
          }
  
          // This is the base, these are at least required
          $otpauth = 'otpauth://' . $type . '/' . rawurlencode($label) . '?secret=' . rawurlencode($secret);
  
          if ($type == 'hotp' && !is_null($counter)) {
              $otpauth .= '&counter=' . intval($counter);
          }
  
          // Now check the options array
  
          // algorithm (currently ignored by Authenticator)
          // Defaults to SHA1
          if (array_key_exists('algorithm', $options)) {
              $otpauth .= '&algorithm=' . rawurlencode($options['algorithm']);
          }
  
          // digits (currently ignored by Authenticator)
          // Defaults to 6
          if (array_key_exists('digits', $options) && intval($options['digits']) !== 6 && intval($options['digits']) !== 8) {
          	throw new \InvalidArgumentException('Digits can only have the values 6 or 8, ' . $options['digits'] . ' given');
          } elseif (array_key_exists('digits', $options)) {
              $otpauth .= '&digits=' . intval($options['digits']);
          }
  
          // period, only for totp (currently ignored by Authenticator)
          // Defaults to 30
          if ($type == 'totp' && array_key_exists('period', $options)) {
              $otpauth .= '&period=' . rawurlencode($options['period']);
          }
  
          // issuer
          // Defaults to none
          if (array_key_exists('issuer', $options)) {
              $otpauth .= '&issuer=' . rawurlencode($options['issuer']);
          }
  
          // image (to accepts images for freeotp)
          if (array_key_exists('image', $options)) {
              $otpauth .= '&image=' . $options['image'];
          }
  
          return $otpauth;
      }
code_tokens: public static function getKeyUri ( $ type , $ label , $ secret , $ counter = null , $ options = array ( ) ) { // two types only.. if ( ! in_array ( $ type , self :: $ allowedTypes ) ) { throw new \ InvalidArgumentException ( 'Type has to be of allowed types list' ) ; } // Label can't be empty $ label = trim ( $ label ) ; if ( strlen ( $ label ) < 1 ) { throw new \ InvalidArgumentException ( 'Label has to be one or more printable characters' ) ; } if ( substr_count ( $ label , ':' ) > 2 ) { throw new \ InvalidArgumentException ( 'Account name contains illegal colon characters' ) ; } // Secret needs to be here if ( strlen ( $ secret ) < 1 ) { throw new \ InvalidArgumentException ( 'No secret present' ) ; } // check for counter on hotp if ( $ type == 'hotp' && is_null ( $ counter ) ) { throw new \ InvalidArgumentException ( 'Counter required for hotp' ) ; } // This is the base, these are at least required $ otpauth = 'otpauth://' . $ type . '/' . rawurlencode ( $ label ) . '?secret=' . rawurlencode ( $ secret ) ; if ( $ type == 'hotp' && ! is_null ( $ counter ) ) { $ otpauth .= '&counter=' . intval ( $ counter ) ; } // Now check the options array // algorithm (currently ignored by Authenticator) // Defaults to SHA1 if ( array_key_exists ( 'algorithm' , $ options ) ) { $ otpauth .= '&algorithm=' . rawurlencode ( $ options [ 'algorithm' ] ) ; } // digits (currently ignored by Authenticator) // Defaults to 6 if ( array_key_exists ( 'digits' , $ options ) && intval ( $ options [ 'digits' ] ) !== 6 && intval ( $ options [ 'digits' ] ) !== 8 ) { throw new \ InvalidArgumentException ( 'Digits can only have the values 6 or 8, ' . $ options [ 'digits' ] . ' given' ) ; } elseif ( array_key_exists ( 'digits' , $ options ) ) { $ otpauth .= '&digits=' . intval ( $ options [ 'digits' ] ) ; } // period, only for totp (currently ignored by Authenticator) // Defaults to 30 if ( $ type == 'totp' && array_key_exists ( 'period' , $ options ) ) { $ otpauth .= '&period=' . rawurlencode ( $ options [ 'period' ] ) ; } // issuer // Defaults to none if ( array_key_exists ( 'issuer' , $ options ) ) { $ otpauth .= '&issuer=' . rawurlencode ( $ options [ 'issuer' ] ) ; } // image (to accepts images for freeotp) if ( array_key_exists ( 'image' , $ options ) ) { $ otpauth .= '&image=' . $ options [ 'image' ] ; } return $ otpauth ; }
docstring: Returns the Key URI
  
  Format of encoded url is here:
  https://code.google.com/p/google-authenticator/wiki/KeyUriFormat
  Should be done in a better fashion
  
  @param string $type totp or hotp
  @param string $label Label to display this as to the user
  @param string $secret Base32 encoded secret
  @param integer $counter Required by hotp, otherwise ignored
  @param array $options Optional fields that will be set if present
  
  @return string Key URI
docstring_tokens: Returns the Key URI