diff options
author | bjoernr-de <dev@bjoernr.de> | 2016-02-17 13:40:18 +0100 |
---|---|---|
committer | bjoernr-de <dev@bjoernr.de> | 2016-02-17 13:40:18 +0100 |
commit | 525756aa812a0c8f283d240336d0fdc07a1e6220 (patch) | |
tree | 530c79ce8872b0366c4ada1e32be167c6038b9c8 | |
parent | 683bda5d67e455b46bb1c297f42400df601f372f (diff) | |
download | php-ssllabs-api-525756aa812a0c8f283d240336d0fdc07a1e6220.zip php-ssllabs-api-525756aa812a0c8f283d240336d0fdc07a1e6220.tar.gz php-ssllabs-api-525756aa812a0c8f283d240336d0fdc07a1e6220.tar.bz2 |
Added getStatusCodes API call
-rw-r--r-- | src/Calls/GetStatusCodesCall.php | 35 | ||||
-rw-r--r-- | src/Objects/StatusCodes.php | 58 |
2 files changed, 91 insertions, 2 deletions
diff --git a/src/Calls/GetStatusCodesCall.php b/src/Calls/GetStatusCodesCall.php new file mode 100644 index 0000000..c5c2208 --- /dev/null +++ b/src/Calls/GetStatusCodesCall.php @@ -0,0 +1,35 @@ +<?php + +namespace BjoernrDe\SSLLabsApi\Calls; +use BjoernrDe\SSLLabsApi\Objects\StatusCodes; + +/** + * API Call 'getStatusCodes' + * + * @author Björn Roland + */ +class GetStatusCodesCall extends GenericCall +{ + /** + * Class constructor + */ + public function __construct() + { + parent::__construct('getStatusCodes', null); + } + + /** + * Send API call + * + * @return BjoernrDe\SSLLabsApi\Objects\StatusCodes + * @see BjoernrDe\SSLLabsApi\Calls\GenericCall::send() + */ + public function send() + { + $response = parent::send(); + + $statusCodesObject = new StatusCodes(); + + return ($statusCodesObject->populateObjectByApiResponse($response)); + } +}
\ No newline at end of file diff --git a/src/Objects/StatusCodes.php b/src/Objects/StatusCodes.php index bf69976..fc103ad 100644 --- a/src/Objects/StatusCodes.php +++ b/src/Objects/StatusCodes.php @@ -1,7 +1,61 @@ <?php namespace BjoernrDe\SSLLabsApi\Objects; -class StatusCodes +class StatusCodes implements ApiObject { - private $statusDetails; + private $statusDetails = array(); + + /** + * Get status details + * + * @return array + */ + public function getStatusDetails() + { + return ($this->statusDetails); + } + + /** + * Set status details + * + * @param array $statusDetails + */ + private function setStatusDetails(array $statusDetails) + { + $this->statusDetails = $statusDetails; + } + + /** + * Get status detail by status code + * + * @param $statusCode + * @return string|bool status detail on success, false on error (i.e. unknown statuscode) + */ + public function getStatusDetail($statusCode) + { + $statusDetails = $this->getStatusDetails(); + + if (isset($statusDetails[$statusCode])) + { + return ($statusDetails[$statusCode]); + } + + return (false); + } + + /** + * /** + * {@inheritDoc} + * + * @return \BjoernrDe\SSLLabsApi\Objects\StatusCodes + * @see \BjoernrDe\SSLLabsApi\Objects\ApiObject::populateObjectByApiResponse() + */ + public function populateObjectByApiResponse($jsonString) + { + $response = json_decode($jsonString); + + isset($response->statusDetails) ? $this->setStatusDetails((array) $response->statusDetails) : ''; + + return ($this); + } }
\ No newline at end of file |