| Server IP : 85.158.181.41 / Your IP : 216.73.217.12 Web Server : Apache System : Linux cloud9-vm129 6.1.178+1-ph #ph SMP PREEMPT_DYNAMIC Wed Jul 29 09:00:54 UTC 2026 x86_64 User : moncbefd ( 1024) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/moncbefd/www.moneta.at/vendor/gambio-hub/hubpublic/src/ValueObjects/ |
Upload File : |
<?php
namespace HubPublic\ValueObjects;
use HubPublic\Exceptions\InvalidAuthHashException;
/**
* Class CartContent
*
* @package HubPublic\ValueObjects
*/
class AuthHash
{
/**
* @var string
*/
private $hash;
/**
* AuthHash constructor.
*
* @param string $hash authorization hash
*
* @throws \HubPublic\Exceptions\InvalidAuthHashException
*/
public function __construct($hash)
{
if ($this->_formatIsValid($hash) !== true) {
throw new InvalidAuthHashException('The given authorization hash is not in a valid format. The entered key was: "' . $hash . '"');
}
$this->hash = $hash;
}
/**
* Returns the authorization hash.
* It is guaranteed that the hash is in a valid format.
*
* @return string Authorization hash
*/
public function asString()
{
return $this->hash;
}
/**
* Checks if the authorization hash is in the correct format. A 32 characters long hexadecimal string.
*
* @param string $hash The key that should be validated
*
* @return bool true if format is valid | false if format is invalid
*/
private function _formatIsValid($hash)
{
return strlen($hash) === 32 && ctype_xdigit($hash);
}
}