From a813b334b359841cac6ed2f35e77cf9a8a44f73e Mon Sep 17 00:00:00 2001 From: boston Date: Tue, 9 Jul 2019 03:12:09 +0300 Subject: [PATCH] up --- README.md | 4 +-- src/MetaHash.php | 75 +++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 66 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 46b659f..64db335 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# MetaHash PHP +# MetaHash API PHP library -PHP library for [#MetaHash](https://metahash.org ) blockchain. +An unofficial PHP library for [#MetaHash](https://metahash.org ) blockchain. ### Requirements diff --git a/src/MetaHash.php b/src/MetaHash.php index 4bed539..3c6694a 100644 --- a/src/MetaHash.php +++ b/src/MetaHash.php @@ -19,18 +19,24 @@ class MetaHash { public const HISTORY_LIMIT = 9999; - - private const CONNECT_TIMEOUT = 2; - private const TIMEOUT = 150; - private const DEBUG = false; - public const NODE_PROXY = 'PROXY'; public const NODE_TORRENT = 'TORRENT'; - public const NETWORK_MAIN = 'main'; public const NETWORK_TEST = 'test'; public const NETWORK_DEV = 'dev'; + /** + * @var int + */ + private $connectTimeout = 2; + /** + * @var int + */ + private $timeout = 150; + /** + * @var bool + */ + private $debug = false; /** * @var string */ @@ -57,20 +63,67 @@ class MetaHash private $client; /** - * Crypto constructor. - * + * MetaHash constructor. */ public function __construct() { $guzzleOptions = [ - 'timeout' => self::TIMEOUT, - 'connect_timeout' => self::CONNECT_TIMEOUT, - 'debug' => self::DEBUG, + 'timeout' => $this->getTimeout(), + 'connect_timeout' => $this->getConnectTimeout(), + 'debug' => $this->getDebug(), ]; $this->setClient(new GuzzleClient($guzzleOptions)); $this->setNetwork(self::NETWORK_MAIN); } + /** + * @return int + */ + public function getTimeout(): int + { + return $this->timeout; + } + + /** + * @param int $timeout + */ + public function setTimeout(int $timeout): void + { + $this->timeout = $timeout; + } + + /** + * @return int + */ + public function getConnectTimeout(): int + { + return $this->connectTimeout; + } + + /** + * @param int $connectTimeout + */ + public function setConnectTimeout(int $connectTimeout): void + { + $this->connectTimeout = $connectTimeout; + } + + /** + * @return bool + */ + public function getDebug(): bool + { + return $this->debug; + } + + /** + * @param bool $debug + */ + public function setDebug(bool $debug): void + { + $this->debug = $debug; + } + /** * Metahash key generate *