class MessageQuery implements MessageQueryInterface mixin ImapQueryBuilder (View source)

Traits

Properties

protected ImapQueryBuilder $query

The query builder instance.

from  QueriesMessages
protected int $page

The current page.

from  QueriesMessages
protected int|null $limit

The fetch limit.

from  QueriesMessages
protected bool $fetchBody

Whether to fetch the message body.

from  QueriesMessages
protected bool $fetchFlags

Whether to fetch the message flags.

from  QueriesMessages
protected bool $fetchHeaders

Whether to fetch the message headers.

from  QueriesMessages
protected bool $fetchSize

Whether to fetch the message size.

from  QueriesMessages
protected bool $fetchBodyStructure

Whether to fetch the message body structure.

from  QueriesMessages
protected "asc"|"desc" $fetchOrder

The fetch order.

from  QueriesMessages
protected bool $fetchAsUnread

Whether to leave messages fetched as unread by default.

from  QueriesMessages
protected array $passthru

The methods that should be returned from query builder.

from  QueriesMessages
protected ImapSortKey|null $sortKey

The sort key for server-side sorting (RFC 5256).

from  QueriesMessages
protected "asc"|"desc" $sortDirection

The sort direction for server-side sorting.

from  QueriesMessages

Methods

mixed
forwardCallTo(object $object, string $method, array $parameters)

Forward a method call to the given object.

static never
throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

mixed
__call(string $method, array $parameters)

Handle dynamic method calls into the query builder.

limit(int $limit, int $page = 1)

{@inheritDoc}

int|null
getLimit()

{@inheritDoc}

setLimit(int $limit)

{@inheritDoc}

int
getPage()

{@inheritDoc}

setPage(int $page)

{@inheritDoc}

bool
isFetchingBody()

{@inheritDoc}

bool
isFetchingFlags()

{@inheritDoc}

bool
isFetchingHeaders()

{@inheritDoc}

bool
isFetchingSize()

{@inheritDoc}

bool
isFetchingBodyStructure()

{@inheritDoc}

setFetchFlags(bool $fetchFlags)

Set whether to fetch the flags.

setFetchBody(bool $fetchBody)

Set the fetch body flag.

setFetchHeaders(bool $fetchHeaders)

Set whether to fetch the headers.

setFetchSize(bool $fetchSize)

Set whether to fetch the size.

setFetchBodyStructure(bool $fetchBodyStructure)

Set whether to fetch the body structure.

setFetchOrder(string $fetchOrder)

{@inheritDoc}

string
getFetchOrder()

{@inheritDoc}

setSortKey(ImapSortKey|string|null $key)

{@inheritDoc}

ImapSortKey|null
getSortKey()

{@inheritDoc}

setSortDirection(string $direction)

{@inheritDoc}

string
getSortDirection()

{@inheritDoc}

sortBy(ImapSortKey|string $key, string $direction = 'asc')

{@inheritDoc}

sortByDesc(ImapSortKey|string $key)

{@inheritDoc}

__construct(FolderInterface $folder, ImapQueryBuilder $query)

Constructor.

int
count()

Count all available messages matching the current search criteria.

first()

Get the first message in the resulting collection.

firstOrFail()

Get the first message in the resulting collection or throw an exception.

get()

Get the messages matching the current query.

int
append(string $message, mixed $flags = null)

Append a new message to the folder.

void
each(callable $callback, int $chunkSize = 10, int $startChunk = 1)

Execute a callback over each message via a chunked query.

void
chunk(callable $callback, int $chunkSize = 10, int $startChunk = 1)

Execute a callback over each chunk of messages.

paginate(int $perPage = 5, $page = null, string $pageName = 'page')

Paginate the current query.

findOrFail(int $id, ImapFetchIdentifier $identifier = ImapFetchIdentifier::Uid)

Find a message by the given identifier type or throw an exception.

find(int $id, ImapFetchIdentifier $identifier = ImapFetchIdentifier::Uid)

Find a message by the given identifier type.

void
destroy(array|int $uids, bool $expunge = false)

Destroy the given messages.

int
flag(BackedEnum|string $flag, string $operation, bool $expunge = false)

Add or remove a flag from all messages matching the current query.

int
markRead()

Mark all messages matching the current query as read.

int
markUnread()

Mark all messages matching the current query as unread.

int
markFlagged()

Mark all messages matching the current query as flagged.

int
unmarkFlagged()

Unmark all messages matching the current query as flagged.

int
delete(bool $expunge = false)

Delete all messages matching the current query.

int
move(string $folder, bool $expunge = false)

Move all messages matching the current query to the given folder.

int
copy(string $folder)

Copy all messages matching the current query to the given folder.

process(Collection $messages)

Process the collection of messages.

populate(Collection $uids)

Populate a given id collection and receive a fully fetched message collection.

array
fetch(Collection $messages)

Fetch a given id collection.

Collection
search()

Execute an IMAP search request.

Collection
sort()

Execute an IMAP UID SORT request using RFC 5256.

id(int $id, ImapFetchIdentifier $identifier = ImapFetchIdentifier::Uid)

Get the UID for the given identifier.

newMessage(int $uid, array $flags, string $head, string $body, int|null $size = null, ListData|null $bodystructure = null)

Make a new message from given raw components.

connection()

Get the connection instance.

Details

protected mixed forwardCallTo(object $object, string $method, array $parameters)

Forward a method call to the given object.

Parameters

object $object
string $method
array $parameters

Return Value

mixed

static protected never throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

Parameters

string $method

Return Value

never

mixed __call(string $method, array $parameters)

Handle dynamic method calls into the query builder.

Parameters

string $method
array $parameters

Return Value

mixed

MessageQueryInterface leaveUnread()

{@inheritDoc}

Return Value

MessageQueryInterface

MessageQueryInterface markAsRead()

{@inheritDoc}

Return Value

MessageQueryInterface

MessageQueryInterface limit(int $limit, int $page = 1)

{@inheritDoc}

Parameters

int $limit
int $page

Return Value

MessageQueryInterface

int|null getLimit()

{@inheritDoc}

Return Value

int|null

MessageQueryInterface setLimit(int $limit)

{@inheritDoc}

Parameters

int $limit

Return Value

MessageQueryInterface

int getPage()

{@inheritDoc}

Return Value

int

MessageQueryInterface setPage(int $page)

{@inheritDoc}

Parameters

int $page

Return Value

MessageQueryInterface

bool isFetchingBody()

{@inheritDoc}

Return Value

bool

bool isFetchingFlags()

{@inheritDoc}

Return Value

bool

bool isFetchingHeaders()

{@inheritDoc}

Return Value

bool

bool isFetchingSize()

{@inheritDoc}

Return Value

bool

bool isFetchingBodyStructure()

{@inheritDoc}

Return Value

bool

MessageQueryInterface withFlags()

{@inheritDoc}

Return Value

MessageQueryInterface

MessageQueryInterface withHeaders()

{@inheritDoc}

Return Value

MessageQueryInterface

MessageQueryInterface withBodyStructure()

{@inheritDoc}

Return Value

MessageQueryInterface

MessageQueryInterface withoutBody()

{@inheritDoc}

Return Value

MessageQueryInterface

MessageQueryInterface withoutHeaders()

{@inheritDoc}

Return Value

MessageQueryInterface

MessageQueryInterface withoutFlags()

{@inheritDoc}

Return Value

MessageQueryInterface

MessageQueryInterface withoutSize()

{@inheritDoc}

Return Value

MessageQueryInterface

MessageQueryInterface withoutBodyStructure()

{@inheritDoc}

Return Value

MessageQueryInterface

protected MessageQueryInterface setFetchFlags(bool $fetchFlags)

Set whether to fetch the flags.

Parameters

bool $fetchFlags

Return Value

MessageQueryInterface

protected MessageQueryInterface setFetchBody(bool $fetchBody)

Set the fetch body flag.

Parameters

bool $fetchBody

Return Value

MessageQueryInterface

protected MessageQueryInterface setFetchHeaders(bool $fetchHeaders)

Set whether to fetch the headers.

Parameters

bool $fetchHeaders

Return Value

MessageQueryInterface

protected MessageQueryInterface setFetchSize(bool $fetchSize)

Set whether to fetch the size.

Parameters

bool $fetchSize

Return Value

MessageQueryInterface

protected MessageQueryInterface setFetchBodyStructure(bool $fetchBodyStructure)

Set whether to fetch the body structure.

Parameters

bool $fetchBodyStructure

Return Value

MessageQueryInterface

MessageQueryInterface setFetchOrder(string $fetchOrder)

{@inheritDoc}

Parameters

string $fetchOrder

Return Value

MessageQueryInterface

string getFetchOrder()

{@inheritDoc}

Return Value

string

MessageQueryInterface setFetchOrderAsc()

{@inheritDoc}

Return Value

MessageQueryInterface

MessageQueryInterface setFetchOrderDesc()

{@inheritDoc}

Return Value

MessageQueryInterface

MessageQueryInterface setSortKey(ImapSortKey|string|null $key)

{@inheritDoc}

Parameters

ImapSortKey|string|null $key

Return Value

MessageQueryInterface

ImapSortKey|null getSortKey()

{@inheritDoc}

Return Value

ImapSortKey|null

MessageQueryInterface setSortDirection(string $direction)

{@inheritDoc}

Parameters

string $direction

Return Value

MessageQueryInterface

string getSortDirection()

{@inheritDoc}

Return Value

string

MessageQueryInterface sortBy(ImapSortKey|string $key, string $direction = 'asc')

{@inheritDoc}

Parameters

ImapSortKey|string $key
string $direction

Return Value

MessageQueryInterface

MessageQueryInterface sortByDesc(ImapSortKey|string $key)

{@inheritDoc}

Parameters

ImapSortKey|string $key

Return Value

MessageQueryInterface

__construct(FolderInterface $folder, ImapQueryBuilder $query)

Constructor.

Parameters

FolderInterface $folder
ImapQueryBuilder $query

int count()

Count all available messages matching the current search criteria.

Return Value

int

MessageInterface|null first()

Get the first message in the resulting collection.

Return Value

MessageInterface|null

MessageInterface firstOrFail()

Get the first message in the resulting collection or throw an exception.

Return Value

MessageInterface

MessageCollection get()

Get the messages matching the current query.

Return Value

MessageCollection

int append(string $message, mixed $flags = null)

Append a new message to the folder.

Parameters

string $message
mixed $flags

Return Value

int

void each(callable $callback, int $chunkSize = 10, int $startChunk = 1)

Execute a callback over each message via a chunked query.

Parameters

callable $callback
int $chunkSize
int $startChunk

Return Value

void

void chunk(callable $callback, int $chunkSize = 10, int $startChunk = 1)

Execute a callback over each chunk of messages.

Parameters

callable $callback
int $chunkSize
int $startChunk

Return Value

void

LengthAwarePaginator paginate(int $perPage = 5, $page = null, string $pageName = 'page')

Paginate the current query.

Parameters

int $perPage
$page
string $pageName

Return Value

LengthAwarePaginator

MessageInterface findOrFail(int $id, ImapFetchIdentifier $identifier = ImapFetchIdentifier::Uid)

Find a message by the given identifier type or throw an exception.

Parameters

int $id
ImapFetchIdentifier $identifier

Return Value

MessageInterface

MessageInterface|null find(int $id, ImapFetchIdentifier $identifier = ImapFetchIdentifier::Uid)

Find a message by the given identifier type.

Parameters

int $id
ImapFetchIdentifier $identifier

Return Value

MessageInterface|null

void destroy(array|int $uids, bool $expunge = false)

Destroy the given messages.

Parameters

array|int $uids
bool $expunge

Return Value

void

int flag(BackedEnum|string $flag, string $operation, bool $expunge = false)

Add or remove a flag from all messages matching the current query.

Parameters

BackedEnum|string $flag
string $operation '+'|'-'
bool $expunge

Return Value

int

The number of messages affected.

int markRead()

Mark all messages matching the current query as read.

Return Value

int

The number of messages affected.

int markUnread()

Mark all messages matching the current query as unread.

Return Value

int

The number of messages affected.

int markFlagged()

Mark all messages matching the current query as flagged.

Return Value

int

The number of messages affected.

int unmarkFlagged()

Unmark all messages matching the current query as flagged.

Return Value

int

The number of messages affected.

int delete(bool $expunge = false)

Delete all messages matching the current query.

Parameters

bool $expunge

Return Value

int

The number of messages affected.

int move(string $folder, bool $expunge = false)

Move all messages matching the current query to the given folder.

Parameters

string $folder
bool $expunge

Return Value

int

The number of messages affected.

int copy(string $folder)

Copy all messages matching the current query to the given folder.

Parameters

string $folder

Return Value

int

The number of messages affected.

protected MessageCollection process(Collection $messages)

Process the collection of messages.

Parameters

Collection $messages

Return Value

MessageCollection

protected MessageCollection populate(Collection $uids)

Populate a given id collection and receive a fully fetched message collection.

Parameters

Collection $uids

Return Value

MessageCollection

protected array fetch(Collection $messages)

Fetch a given id collection.

Parameters

Collection $messages

Return Value

array

Execute an IMAP search request.

Return Value

Collection

protected Collection sort()

Execute an IMAP UID SORT request using RFC 5256.

Return Value

Collection

protected ResponseCollection id(int $id, ImapFetchIdentifier $identifier = ImapFetchIdentifier::Uid)

Get the UID for the given identifier.

Parameters

int $id
ImapFetchIdentifier $identifier

Return Value

ResponseCollection

protected Message newMessage(int $uid, array $flags, string $head, string $body, int|null $size = null, ListData|null $bodystructure = null)

Make a new message from given raw components.

Parameters

int $uid
array $flags
string $head
string $body
int|null $size
ListData|null $bodystructure

Return Value

Message

protected ConnectionInterface connection()

Get the connection instance.

Return Value

ConnectionInterface