MCPcopy Create free account
hub / github.com/GDATASoftwareAG/vaas / TryFromString

Method TryFromString

php/src/vaas/Sha256.php:46–56  ·  view source on GitHub ↗

* Gets Sha256 from string * @param string $hashString the string to create the hash from * @return Future that resolves to the sha256 object * @throws InvalidSha256Exception if the hash is invalid */

(string $hashString)

Source from the content-addressed store, hash-verified

44 * @throws InvalidSha256Exception if the hash is invalid
45 */
46 public static function TryFromString(string $hashString): Future
47 {
48 return async(function () use($hashString) {
49 if (Sha256::IsValid($hashString)->await()) {
50 $sha256 = new Sha256();
51 $sha256->_hash = $hashString;
52 return $sha256;
53 }
54 throw new InvalidSha256Exception();
55 });
56 }
57
58 /**
59 * Validates a hash to be a valid sha256

Calls 1

IsValidMethod · 0.45