public function forget(string $key, string $value = null): bool
    {
        $storageInstance = null;

        try {
            $storageInstance = $this->getRepository();
        } catch (\Exception $e) {
            return false;
        }

        // Delete a single token with this key and check if there are multiple tokens associated with this key
        if($value && isset($storageInstance->{$key}) && is_array($storageInstance->{$key}) && count($storageInstance->{$key}) > 1)
        {
            // Find our token in list of tokens
            $index = array_search($value, $storageInstance->{$key});

            if (isset($index) && isset($storageInstance->{$key}[$index])) {
                // Remove single token from list
                unset($storageInstance->{$key}[$index]);

                if (count($storageInstance->{$key}) === 0) {
                    // No more tokens left, remove key
                    unset($storageInstance->{$key});
                } else {
                    // Reset array key after removing an key
                    $storageInstance->{$key} = array_values($storageInstance->{$key});
                }

                $this->updateRepository($storageInstance);

                return !in_array($value, $storageInstance->{$key});
            }
        } else {
            // Delete all tokens with this key
            unset($storageInstance->{$key});

            $this->updateRepository($storageInstance);

            return !isset($storageInstance->{$key});
        }

        return false;
    }
public function forget(string $key, string $value = null): bool
    {
        $storageInstance = null;

        try {
            $storageInstance = $this->getRepository();
        } catch (\Exception $e) {
            return false;
        }

        // Delete a single token with this key and check if there are multiple tokens associated with this key
        if($value && isset($storageInstance->{$key}) && is_array($storageInstance->{$key}) && count($storageInstance->{$key}) > 1)
        {
            // Find our token in list of tokens
            $index = array_search($value, $storageInstance->{$key});

            if (isset($index) && isset($storageInstance->{$key}[$index])) {
                // Remove single token from list
                unset($storageInstance->{$key}[$index]);

                if (count($storageInstance->{$key}) === 0) {
                    // No more tokens left, remove key
                    unset($storageInstance->{$key});
                } else {
                    // Reset array key after removing an key
                    $storageInstance->{$key} = array_values($storageInstance->{$key});
                }

                $this->updateRepository($storageInstance);

                return !in_array($value, $storageInstance->{$key});
            }
        } else {
            // Delete all tokens with this key
            unset($storageInstance->{$key});

            $this->updateRepository($storageInstance);

            return !isset($storageInstance->{$key});
        }

        return false;
    }
public function forget ( string $ key , string $ value = null ) : bool { $ storageInstance = null ; try { $ storageInstance = $ this -> getRepository ( ) ; } catch ( \ Exception $ e ) { return false ; } // Delete a single token with this key and check if there are multiple tokens associated with this key if ( $ value && isset ( $ storageInstance -> { $ key } ) && is_array ( $ storageInstance -> { $ key } ) && count ( $ storageInstance -> { $ key } ) > 1 ) { // Find our token in list of tokens $ index = array_search ( $ value , $ storageInstance -> { $ key } ) ; if ( isset ( $ index ) && isset ( $ storageInstance -> { $ key } [ $ index ] ) ) { // Remove single token from list unset ( $ storageInstance -> { $ key } [ $ index ] ) ; if ( count ( $ storageInstance -> { $ key } ) === 0 ) { // No more tokens left, remove key unset ( $ storageInstance -> { $ key } ) ; } else { // Reset array key after removing an key $ storageInstance -> { $ key } = array_values ( $ storageInstance -> { $ key } ) ; } $ this -> updateRepository ( $ storageInstance ) ; return ! in_array ( $ value , $ storageInstance -> { $ key } ) ; } } else { // Delete all tokens with this key unset ( $ storageInstance -> { $ key } ) ; $ this -> updateRepository ( $ storageInstance ) ; return ! isset ( $ storageInstance -> { $ key } ) ; } return false ; }
Removes an Expo token with a given identifier

@param string $key
@param string $value

@return bool
Removes an Expo token with a given identifier