summaryrefslogtreecommitdiffstats
path: root/src/Calls/AnalyzeCall.php
blob: aed1e39675ae562ee68c756e5c74b5495209ea7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace BjoernrDe\SSLLabsApi\Calls;

use BjoernrDe\SSLLabsApi\Objects\Host;
use BjoernrDe\SSLLabsApi\Exceptions\InvalidScopeException;
use BjoernrDe\SSLLabsApi\Exceptions\MissingApiParameterException;

/**
 * API Call 'analyze'
 * 
 * @author Björn Roland
 */
class AnalyzeCall extends GenericCall
{
	/**
	 * Class constructor
	 * 
	 * @param array $parameters
	 */
	public function __construct($parameters = array())
	{
		if (!is_array($parameters))
		{
			throw new InvalidScopeException('Parameters must be an array');
		}
		if (!isset($parameters['host']) || empty($parameters['host']))
		{
			throw new MissingApiParameterException('Missing host parameter');
		}
		
		parent::__construct('analyze', $parameters);
	}
	
	/**
	 * Send API call
	 * 
	 * @return BjoernrDe\SSLLabsApi\Objects\Host
	 * @see BjoernrDe\SSLLabsApi\Calls\GenericCall::send()
	 */
	public function send()
	{
		$response = parent::send();
		$hostObject = new Host();
		
		return ($hostObject->populateObjectByApiResponse($response));
	}
}