| Total Complexity | 9 |
| Total Lines | 69 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | class Shodan |
||
| 18 | { |
||
| 19 | private $_url; |
||
| 20 | |||
| 21 | private $_results; |
||
| 22 | |||
| 23 | private $_data; |
||
| 24 | |||
| 25 | public function __construct() |
||
| 26 | { |
||
| 27 | $this->_results = null; |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Add URL to be checked with Shodan API. |
||
| 32 | * |
||
| 33 | * @param string $url The URL to be checked. |
||
| 34 | * |
||
| 35 | * @return Shodan. |
||
| 36 | */ |
||
| 37 | public function setUrl(string $url) |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Checks a given URL with Shodan API. |
||
| 46 | * |
||
| 47 | * @return Shodan |
||
| 48 | * |
||
| 49 | * @throws ErrorException |
||
| 50 | */ |
||
| 51 | public function check() |
||
| 52 | { |
||
| 53 | $error = [ |
||
| 54 | 'status' => 500, |
||
| 55 | 'response' => 'URL cannot be null.' |
||
| 56 | ]; |
||
| 57 | |||
| 58 | $this->_results = empty($this->getUrl()) || empty($this->_data) ? |
||
| 59 | $error : (new Curl($this->_data))->getData(); |
||
| 60 | |||
| 61 | return $this; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Get current URL. |
||
| 66 | * |
||
| 67 | * @return string|null |
||
| 68 | */ |
||
| 69 | public function getUrl(){ |
||
| 70 | return $this->_url; |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Get results of Shodan API call. |
||
| 75 | * |
||
| 76 | * @param bool $jsonEncode Encode results as JSON, or |
||
| 77 | * return as associative arrag. |
||
| 78 | * @return mixed|null |
||
| 79 | */ |
||
| 80 | public function getResults(bool $jsonEncode = false){ |
||
| 86 | } |
||
| 87 | } |
||
| 88 |