Snuze  0.8.1
snuze\Persistence\Interfaces\MapperInterface Interface Reference
Inheritance diagram for snuze\Persistence\Interfaces\MapperInterface:

Public Member Functions

 __construct (StorageProviderInterface $storage)
 
 persist ($object)
 
 retrieve ($key)
 
 delete ($object)
 

Detailed Description

The MapperInterface is part of the storage provider design.

It defines methods that must be implemented by any Mapper object when developing a storage provider for Snuze.


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\Interfaces\MapperInterface::__construct ( StorageProviderInterface  $storage)

A Mapper's constructor must accept a storage provider (for example, a MySQL or SQLite storage provider) implementing StorageProviderInterface.

Parameters
\snuze\Persistence\Provider\StorageProviderInterface$storage

Implemented in snuze\Persistence\MySQL\AccountMapper, snuze\Persistence\SQLite\AccessTokenMapper, snuze\Persistence\MySQL\AccessTokenMapper, snuze\Persistence\MySQL\LinkMapper, and snuze\Persistence\MySQL\SubredditMapper.

Member Function Documentation

◆ delete()

snuze\Persistence\Interfaces\MapperInterface::delete (   $object)

Delete an object from storage.

Parameters
object$objectThe object to delete
Returns
bool True on success; an exception should be thrown on error

Implemented in snuze\Persistence\MySQL\LinkMapper, snuze\Persistence\MySQL\SubredditMapper, snuze\Persistence\MySQL\AccountMapper, snuze\Persistence\SQLite\AccessTokenMapper, and snuze\Persistence\MySQL\AccessTokenMapper.

◆ persist()

snuze\Persistence\Interfaces\MapperInterface::persist (   $object)

Persist the object to storage. This must support both the insertion of new objects and the updating of existing objects; implementers should use the equivalent of an "upsert" paradigm.

Parameters
object$objectThe object to persist
Returns
bool True on success; an exception should be thrown on error

Implemented in snuze\Persistence\MySQL\AccountMapper, snuze\Persistence\SQLite\AccessTokenMapper, snuze\Persistence\MySQL\AccessTokenMapper, snuze\Persistence\MySQL\LinkMapper, and snuze\Persistence\MySQL\SubredditMapper.

◆ retrieve()

snuze\Persistence\Interfaces\MapperInterface::retrieve (   $key)

Retrieve an object from storage, given a unique identifier for it. The identifier used is left up to the implementer. A SubredditMapper may use the subreddit's name as the default retrieval key, whereas a LinkMapper would use the link's internal Reddit ID, etc. You can always extend the built-in mappers to add your own methods with different criteria.

Parameters
mixed$keyA unique identifier for the object to be retrieved.

Implemented in snuze\Persistence\MySQL\LinkMapper, snuze\Persistence\MySQL\SubredditMapper, snuze\Persistence\MySQL\AccountMapper, snuze\Persistence\SQLite\AccessTokenMapper, snuze\Persistence\MySQL\AccessTokenMapper, snuze\Persistence\Interfaces\AccountMapperInterface, and snuze\Persistence\Interfaces\SubredditMapperInterface.


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