<?php

namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Hashes;

use FernleafSystems\Wordpress\Services\Utilities\HttpRequest;

/**
 * Class Ping
 * @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Hashes
 */
class Ping extends Base {

	const API_ENDPOINT = 'ping';

	/**
	 * @return bool
	 */
	public function ping() {
		$sResponse = ( new HttpRequest() )->getContent( $this->getApiUrl() );
		$aR = empty( $sResponse ) ? null : json_decode( $sResponse, true );
		return ( is_array( $aR ) && isset( $aR[ 'pong' ] ) ) ? ( $aR[ 'pong' ] == 'ping' ) : false;
	}
}