phpDocumentor

EmailReader
in package
implements EmailReaderInterface Uses HtmlUtilityTrait

Class EmailReader

Reads email records from the database. This class provides a customizable interface for reading operations so that it is possible to build different variations in the EmailRepository class (e.g. "getPending", "findById", "getAll").

Tags
category

System

subpackage

Repository

Interfaces, Classes and Traits

EmailReaderInterface
Interface EmailReaderInterface

Table of Contents

$db  : CI_DB_query_builder
Query builder.
$factory  : EmailFactory
E-Mail factory.
__construct()  : mixed
Class Constructor
filter()  : EmailCollection
Filter email records with provided keyword string.
get()  : EmailCollection
Get email records filtered by conditions.
getRecordCount()  : int
Get the current count of the email records in the database.
htmlentitiesWrapper()  : mixed
htmlEntityDecodeWrapper()  : mixed
_createEmailByArray()  : Email
Creates an email object out of an array.
_filter()  : mixed
Apply filter rules to email records.
_limit()  : mixed
Apply LIMIT clause to query.
_order()  : mixed
Apply ORDER BY clause to query.

Properties

Methods

__construct()

Class Constructor

public __construct(CI_DB_query_builder $db, EmailFactoryInterface $factory) : mixed
Parameters
$db : CI_DB_query_builder

Will be used for database operations.

$factory : EmailFactoryInterface

Will be used for the creation of returned objects.

Return values
mixed

filter()

Filter email records with provided keyword string.

public filter(string $p_keyword[, array<string|int, mixed> $limit = [] ][, array<string|int, mixed> $order = [] ]) : EmailCollection
Parameters
$p_keyword : string

String to be used for filtering the email records.

$limit : array<string|int, mixed> = []

(optional) Array that contains LIMIT and OFFSET value e.g. array( 'limit' => 10, 'offset' => 5 )

$order : array<string|int, mixed> = []

(optional) Contains arrays with column, direction pairs e.g. array( 'column' => 'direction' )

Return values
EmailCollection

Returns a collection containing the email records.

get()

Get email records filtered by conditions.

public get([array<string|int, mixed> $conditions = [] ][, array<string|int, mixed> $limit = [] ][, array<string|int, mixed> $order = [] ]) : EmailCollection

Example: $reader->get(array('email_id' => $customerId), 10, array( array('email_id', 'asc') ));

Parameters
$conditions : array<string|int, mixed> = []

(optional) Contains conditions with column => value pairs.

$limit : array<string|int, mixed> = []

(optional) Array that contains LIMIT and OFFSET value e.g. array( 'limit' => 10, 'offset' => 5 )

$order : array<string|int, mixed> = []

(optional) Contains arrays with column, direction pairs e.g. array( 'column' => 'direction' )

Return values
EmailCollection

Returns a collection containing the email records.

getRecordCount()

Get the current count of the email records in the database.

public getRecordCount([string $p_filterKeyword = '' ]) : int

This method will quickly return the record count of the "emails" table. It must be used when we just need the number and not the data, because the "get" or "find" methods need more time to load and parse the records.

Parameters
$p_filterKeyword : string = ''

(optional) If provided the records will be filtered.

Tags
throws
InvalidArgumentException

If the provided argument is not a string.

Return values
int

Returns the row number of the email table.

htmlentitiesWrapper()

public htmlentitiesWrapper(mixed $string[, mixed $flags = false ][, mixed $encoding = '' ][, mixed $doubleEncode = true ]) : mixed
Parameters
$string : mixed
$flags : mixed = false
$encoding : mixed = ''
$doubleEncode : mixed = true
Return values
mixed

htmlEntityDecodeWrapper()

public htmlEntityDecodeWrapper(mixed $string[, mixed $flags = false ][, mixed $encoding = '' ]) : mixed
Parameters
$string : mixed
$flags : mixed = false
$encoding : mixed = ''
Return values
mixed

_createEmailByArray()

Creates an email object out of an array.

protected _createEmailByArray(array<string|int, mixed> $emailDataArray) : Email

This method expects the following values to be present in the array: 'email_id', 'subject', 'content', 'is_pending', 'contacts', 'attachments'. It uses the EmailFactory for creating email objects.

Parameters
$emailDataArray : array<string|int, mixed>

Contains the database record information.

Tags
throws
UnexpectedValueException

If the 'creation_date' of the email is empty.

Return values
Email

Returns an object that represents the database record.

_filter()

Apply filter rules to email records.

protected _filter(string $p_keyword) : mixed

This method will set the SQL filters depending the provided keyword so that one can "get" the filtered records.

Parameters
$p_keyword : string

Filtering keyword to be applied in the query.

Tags
throws
InvalidArgumentException

If the $keyword argument is not a string.

Return values
mixed

Search results