for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace rdx\imap;
abstract class IMAPMessageContent {
protected $structure; // stdClass
protected $parts = []; // Array<rdx\imap\IMAPMessagePart>
protected $parameters = [];
public function allParts( $withContainers = false ) {
$parts = [];
$iterate = function($message) use (&$iterate, &$parts, $withContainers) {
foreach ( $message->parts() as $part ) {
if ( $part->parts() ) {
if ( $withContainers ) {
$parts[] = $part;
}
$iterate($part);
else {
};
$iterate($this);
return $parts;
public function part( $index ) {
$parts = $this->parts();
return @$parts[$index];
public function parameters() {
if ( empty($this->parameters) ) {
$structure = $this->structure();
$this->parameters['bytes'] = @$structure->bytes;
foreach ((array) @$structure->parameters as $param) {
$this->parameters[ strtolower($param->attribute) ] = $param->value;
foreach ((array) @$structure->dparameters as $param) {
return $this->parameters;
public function parameter( $name ) {
$parameters = $this->parameters();
return @$parameters[ strtolower($name) ];