src/Utility/TokenTrait.php
public function check($token, array $options = [])
    {
        $conditions = compact('token');

        foreach (['user_id', 'type'] as $key) {
            $conditions[$key] = array_key_exists($key, $options) ? $options[$key] : null;
        }

        return !$this->find($conditions)->isEmpty();
    }
public function check($token, array $options = [])
    {
        $conditions = compact('token');

        foreach (['user_id', 'type'] as $key) {
            $conditions[$key] = array_key_exists($key, $options) ? $options[$key] : null;
        }

        return !$this->find($conditions)->isEmpty();
    }
public function check ( $ token , array $ options = [ ] ) { $ conditions = compact ( 'token' ) ; foreach ( [ 'user_id' , 'type' ] as $ key ) { $ conditions [ $ key ] = array_key_exists ( $ key , $ options ) ? $ options [ $ key ] : null ; } return ! $ this -> find ( $ conditions ) -> isEmpty ( ) ; }
Checks if a token exists and is active.

Valid optios values: `user_id`, `type`.

Be careful: if the token has these options, then you must set them.
In other words, blank options will be replaced with `null`.
@param string $token Token value
@param array $options Options
@return bool
@uses find()
Checks if a token exists and is active .