Snuze  0.8.1
snuze\Persistence\SQLite\AccessTokenMapper Class Reference
Inheritance diagram for snuze\Persistence\SQLite\AccessTokenMapper:

Public Member Functions

 __construct (StorageProviderInterface $storage)
 
 persist ($accessToken)
 
 retrieve ($key)
 
 retrieveOneFor (string $username)
 
 delete ($object)
 
 purge (int $olderThan=86400)
 
- Public Member Functions inherited from snuze\SnuzeObject
 __construct (array $args=null)
 
 _getSnuzeId ()
 
 _getSnuzeClass ()
 
 _ident ()
 

Private Attributes

 $pdo = null
 

Additional Inherited Members

- Protected Member Functions inherited from snuze\SnuzeObject
 debug (string $message, bool $echo=false)
 
 info (string $message, bool $echo=false)
 
 warning (string $message, bool $echo=false)
 
 error (string $message, bool $echo=false)
 
- Protected Attributes inherited from snuze\SnuzeObject
 $_snuzeId = null
 
 $_snuzeClass = null
 

Detailed Description

A data mapper class for AccessToken objects using the SQLite StorageProvider.

This is where abstraction goes to die.


This file is part of Snuze, a PHP client for the Reddit API. Copyright 2019 Shaun Cummiskey shaun.nosp@m.@sha.nosp@m.unc.c.nosp@m.om https://shaunc.com/ Repository: https://github.com/snuze/snuze/ Documentation: https://snuze.shaunc.com/

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Constructor & Destructor Documentation

◆ __construct()

snuze\Persistence\SQLite\AccessTokenMapper::__construct ( StorageProviderInterface  $storage)
Parameters
\snuze\Persistence\SQLite\StorageProvider$storageA SQLite StorageProvider object
Exceptions

Implements snuze\Persistence\Interfaces\MapperInterface.

Member Function Documentation

◆ delete()

snuze\Persistence\SQLite\AccessTokenMapper::delete (   $object)
Parameters
\snuze\Reddit\AccessToken$objectThe AccessToken to delete
Returns
bool True on success; otherwise, an exception is thrown
Exceptions

Implements snuze\Persistence\Interfaces\MapperInterface.

◆ persist()

snuze\Persistence\SQLite\AccessTokenMapper::persist (   $accessToken)

Insert or update an AccessToken to the SQLite database.

Parameters
\snuze\Reddit\AccessToken$accessTokenThe AccessToken to persist
Returns
bool True on success; otherwise, an exception is thrown
Exceptions

Implements snuze\Persistence\Interfaces\MapperInterface.

◆ purge()

snuze\Persistence\SQLite\AccessTokenMapper::purge ( int  $olderThan = 86400)

Delete expired AccessTokens from the database. This is called by Snuze prior to persisting a new token.

Parameters
int$olderThanTokens that expired more than this many seconds ago will be deleted. Defaults to 1 day.
Exceptions

Implements snuze\Persistence\Interfaces\AccessTokenMapperInterface.

◆ retrieve()

snuze\Persistence\SQLite\AccessTokenMapper::retrieve (   $key)

Get an AccessToken from the database by its token field.

Parameters
string$keyThe token field of the AccessToken to retrieve. It's the only unique property of an AccessToken.
Returns
\snuze\Reddit\AccessToken|null

Implements snuze\Persistence\Interfaces\MapperInterface.

◆ retrieveOneFor()

snuze\Persistence\SQLite\AccessTokenMapper::retrieveOneFor ( string  $username)

Get the newest unexpired access token for the specified user, if one exists.

Parameters
string$usernameThe username for whom to retrieve a token
Returns
\snuze\Reddit\AccessToken|null An AccessToken object, or null if there was no matching row
Exceptions

Implements snuze\Persistence\Interfaces\AccessTokenMapperInterface.


The documentation for this class was generated from the following file: