<?php

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

use FernleafSystems\Wordpress\Services\Services;

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

	const API_ENDPOINT = 'plugin';

	/**
	 * @param string $sVersion
	 * @param string $sLocale
	 * @param string $sHashAlgo
	 * @return string[]|null
	 */
	public function getHashes( $sVersion, $sLocale = null, $sHashAlgo = null ) {
		$oReq = new HashesRequestVO();
		$oReq->version = $sVersion;
		$oReq->hash = $sHashAlgo;
		$oReq->locale = strtolower( empty( $sLocale ) ? Services::WpGeneral()->getLocaleForChecksums() : $sLocale );
		return $this->queryHashes( $oReq );
	}

	/**
	 * @return string[]|null
	 */
	public function getCurrent() {
		$oWp = Services::WpGeneral();
		return $this->getHashes( $oWp->getVersion(), $oWp->getLocaleForChecksums(), $this->getHashAlgo() );
	}
}