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 Repository: Documentation:

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

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)
\snuze\Persistence\SQLite\StorageProvider$storageA SQLite StorageProvider object

Implements snuze\Persistence\Interfaces\MapperInterface.

Member Function Documentation

◆ delete()

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

Implements snuze\Persistence\Interfaces\MapperInterface.

◆ persist()

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

Insert or update an AccessToken to the SQLite database.

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

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.

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

Implements snuze\Persistence\Interfaces\AccessTokenMapperInterface.

◆ retrieve()

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

Get an AccessToken from the database by its token field.

string$keyThe token field of the AccessToken to retrieve. It's the only unique property of an AccessToken.

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.

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

Implements snuze\Persistence\Interfaces\AccessTokenMapperInterface.

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