Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
phpdoc annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
liamdennehy committed Jul 30, 2019
1 parent fe91c52 commit e62d824
Showing 1 changed file with 63 additions and 2 deletions.
65 changes: 63 additions & 2 deletions src/Key.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class Key
private $type;

/**
* @param string $id
* @param string $secret
* @param string $id
* @param string|array $secret
*/
public function __construct($id, $item)
{
Expand Down Expand Up @@ -59,6 +59,14 @@ public function __construct($id, $item)
}
}

/**
* Retrieves private key resource from a input string or
* array of strings.
*
* @param string|array $object PEM-format Private Key or file path to same
*
* @return resource|false
*/
public static function getPrivateKey($object)
{
if (is_array($object)) {
Expand All @@ -80,6 +88,14 @@ public static function getPrivateKey($object)
}
}

/**
* Retrieves public key resource from a input string or
* array of strings.
*
* @param string|array $object PEM-format Public Key or file path to same
*
* @return resource|false
*/
public static function getPublicKey($object)
{
if (is_array($object)) {
Expand All @@ -102,11 +118,25 @@ public static function getPublicKey($object)
}
}

/**
* Signing HTTP Messages 'keyId' field.
*
* @return string
*
* @throws KeyException
*/
public function getId()
{
return $this->id;
}

/**
* Retrieve Verifying Key - Public Key for Asymmetric/PKI, or shared secret for HMAC.
*
* @return string Shared Secret or PEM-format Public Key
*
* @throws KeyException
*/
public function getVerifyingKey()
{
switch ($this->type) {
Expand All @@ -124,6 +154,13 @@ public function getVerifyingKey()
}
}

/**
* Retrieve Signing Key - Private Key for Asymmetric/PKI, or shared secret for HMAC.
*
* @return string Shared Secret or PEM-format Private Key
*
* @throws KeyException
*/
public function getSigningKey()
{
switch ($this->type) {
Expand All @@ -143,11 +180,21 @@ public function getSigningKey()
}
}

/**
* @return string 'secret' for HMAC or 'asymmetric'
*/
public function getType()
{
return $this->type;
}

/**
* Test if $object is, points to or contains, X.509 PEM-format certificate.
*
* @param string|array $object PEM Format X.509 Certificate or file path to one
*
* @return bool
*/
public static function hasX509Certificate($object)
{
if (is_array($object)) {
Expand All @@ -169,6 +216,13 @@ public static function hasX509Certificate($object)
}
}

/**
* Test if $object is, points to or contains, PEM-format Public Key.
*
* @param string|array $object PEM-format Public Key or file path to one
*
* @return bool
*/
public static function hasPublicKey($object)
{
if (is_array($object)) {
Expand All @@ -183,6 +237,13 @@ public static function hasPublicKey($object)
}
}

/**
* Test if $object is, points to or contains, PEM-format Private Key.
*
* @param string|array $object PEM-format Private Key or file path to one
*
* @return bool
*/
public static function hasPrivateKey($object)
{
if (is_array($object)) {
Expand Down

0 comments on commit e62d824

Please sign in to comment.