Skip to content

Commit

Permalink
Merge pull request #62 from johanderuijter/docblock
Browse files Browse the repository at this point in the history
Aligned the DocBlocks
  • Loading branch information
robertdimarco committed Jul 16, 2015
2 parents 436e005 + ebf6b25 commit 11855db
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions src/JWT.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ class JWT
/**
* Decodes a JWT string into a PHP object.
*
* @param string $jwt The JWT
* @param string|Array|null $key The secret key, or map of keys
* @param Array $allowed_algs List of supported verification algorithms
* @param string $jwt The JWT
* @param string|array|null $key The key, or map of keys.
* If the algorithm used is asymmetric, this is the public key
* @param array $allowed_algs List of supported verification algorithms
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
*
* @return object The JWT's payload as a PHP object
* @return object The JWT's payload as a PHP object
*
* @throws DomainException Algorithm was not provided
* @throws UnexpectedValueException Provided JWT was invalid
Expand Down Expand Up @@ -120,13 +122,15 @@ public static function decode($jwt, $key = null, $allowed_algs = array())
/**
* Converts and signs a PHP object or array into a JWT string.
*
* @param object|array $payload PHP object or array
* @param string $key The secret key
* @param string $alg The signing algorithm. Supported
* algorithms are 'HS256', 'HS384' and 'HS512'
* @param array $head An array with header elements to attach
* @param object|array $payload PHP object or array
* @param string $key The secret key.
* If the algorithm used is asymmetric, this is the private key
* @param string $alg The signing algorithm.
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
* @param array $head An array with header elements to attach
*
* @return string A signed JWT
*
* @return string A signed JWT
* @uses jsonEncode
* @uses urlsafeB64Encode
*/
Expand All @@ -153,12 +157,13 @@ public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $he
/**
* Sign a string with a given key and algorithm.
*
* @param string $msg The message to sign
* @param string|resource $key The secret key
* @param string $alg The signing algorithm. Supported algorithms
* are 'HS256', 'HS384', 'HS512' and 'RS256'
* @param string $msg The message to sign
* @param string|resource $key The secret key
* @param string $alg The signing algorithm.
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
*
* @return string An encrypted message
*
* @return string An encrypted message
* @throws DomainException Unsupported algorithm was specified
*/
public static function sign($msg, $key, $alg = 'HS256')
Expand All @@ -182,13 +187,16 @@ public static function sign($msg, $key, $alg = 'HS256')
}

/**
* Verify a signature with the mesage, key and method. Not all methods
* Verify a signature with the message, key and method. Not all methods
* are symmetric, so we must have a separate verify and sign method.
* @param string $msg the original message
* @param string $signature
* @param string|resource $key for HS*, a string key works. for RS*, must be a resource of an openssl public key
* @param string $alg
*
* @param string $msg The original message (header and body)
* @param string $signature The original signature
* @param string|resource $key For HS*, a string key works. for RS*, must be a resource of an openssl public key
* @param string $alg The algorithm
*
* @return bool
*
* @throws DomainException Invalid Algorithm or OpenSSL failure
*/
private static function verify($msg, $signature, $key, $alg)
Expand Down Expand Up @@ -229,7 +237,8 @@ private static function verify($msg, $signature, $key, $alg)
*
* @param string $input JSON string
*
* @return object Object representation of JSON string
* @return object Object representation of JSON string
*
* @throws DomainException Provided string was invalid JSON
*/
public static function jsonDecode($input)
Expand Down Expand Up @@ -263,7 +272,8 @@ public static function jsonDecode($input)
*
* @param object|array $input A PHP object or array
*
* @return string JSON representation of the PHP object or array
* @return string JSON representation of the PHP object or array
*
* @throws DomainException Provided object could not be encoded to valid JSON
*/
public static function jsonEncode($input)
Expand Down Expand Up @@ -331,6 +341,7 @@ private static function handleJsonError($errno)
* Get the number of bytes in cryptographic strings.
*
* @param string
*
* @return int
*/
private static function safeStrlen($str)
Expand Down

0 comments on commit 11855db

Please sign in to comment.