public function getDecodeHash(string $hash): array
    {
        $decode = base64_decode($hash);
        list($part1, $part2) = explode(self::PART_SEPARATOR, $decode);

        $p1 = explode(self::TIME_SEPARATOR, $part1);
        list($linkValidate,) = $p1; // get validate int

        $id = null;
        $verifyHash = null;
        $dateNow = new DateTime();
        $dateValidate = $dateNow;
        if ($linkValidate == self::NO_TIME) {
            // parameter $linkValidate is null -> generate now
            $linkValidate = $dateNow->getTimestamp();
        }
        $dateValidate->setTimestamp((int) $linkValidate);  // convert validate int do datetime
        if ($dateValidate >= $dateNow) {   // check expiration
            $p2 = explode(self::ID_SEPARATOR, $part2);
            $verifyHash = implode('.', array_slice($p2, 0, -1));  // regenerate hash
            $id = $p2[count($p2) - 1];  // get id from last part
        } else {
            throw new IdentityException('Activate link is expired!');
        }
        return ['id' => $id, 'verifyHash' => $verifyHash, 'expired' => (int) $linkValidate];
    }
public function getDecodeHash(string $hash): array
    {
        $decode = base64_decode($hash);
        list($part1, $part2) = explode(self::PART_SEPARATOR, $decode);

        $p1 = explode(self::TIME_SEPARATOR, $part1);
        list($linkValidate,) = $p1; // get validate int

        $id = null;
        $verifyHash = null;
        $dateNow = new DateTime();
        $dateValidate = $dateNow;
        if ($linkValidate == self::NO_TIME) {
            // parameter $linkValidate is null -> generate now
            $linkValidate = $dateNow->getTimestamp();
        }
        $dateValidate->setTimestamp((int) $linkValidate);  // convert validate int do datetime
        if ($dateValidate >= $dateNow) {   // check expiration
            $p2 = explode(self::ID_SEPARATOR, $part2);
            $verifyHash = implode('.', array_slice($p2, 0, -1));  // regenerate hash
            $id = $p2[count($p2) - 1];  // get id from last part
        } else {
            throw new IdentityException('Activate link is expired!');
        }
        return ['id' => $id, 'verifyHash' => $verifyHash, 'expired' => (int) $linkValidate];
    }
public function getDecodeHash ( string $ hash ) : array { $ decode = base64_decode ( $ hash ) ; list ( $ part1 , $ part2 ) = explode ( self :: PART_SEPARATOR , $ decode ) ; $ p1 = explode ( self :: TIME_SEPARATOR , $ part1 ) ; list ( $ linkValidate , ) = $ p1 ; // get validate int $ id = null ; $ verifyHash = null ; $ dateNow = new DateTime ( ) ; $ dateValidate = $ dateNow ; if ( $ linkValidate == self :: NO_TIME ) { // parameter $linkValidate is null -> generate now $ linkValidate = $ dateNow -> getTimestamp ( ) ; } $ dateValidate -> setTimestamp ( ( int ) $ linkValidate ) ; // convert validate int do datetime if ( $ dateValidate >= $ dateNow ) { // check expiration $ p2 = explode ( self :: ID_SEPARATOR , $ part2 ) ; $ verifyHash = implode ( '.' , array_slice ( $ p2 , 0 , - 1 ) ) ; // regenerate hash $ id = $ p2 [ count ( $ p2 ) - 1 ] ; // get id from last part } else { throw new IdentityException ( 'Activate link is expired!' ) ; } return [ 'id' => $ id , 'verifyHash' => $ verifyHash , 'expired' => ( int ) $ linkValidate ] ; }
Get decode link.

@param string $hash
@return array
@throws IdentityException
@throws \Exception
Get decode link .