Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
2.2 kB · 119 lines
PHP
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120<?php
namespace PhpMimeMailParser;
/** * Mime Part * Represents the results of mailparse_msg_get_part_data() * * Note ArrayAccess::offsetSet() cannot modify deeply nestated arrays. * When modifying use getPart() and setPart() for deep nested data modification * * @example * * $MimePart['headers']['from'] = 'modified@example.com' // fails * * // correct * $part = $MimePart->getPart(); * $part['headers']['from'] = 'modified@example.com'; * $MimePart->setPart($part); */class MimePart implements \ArrayAccess{ /** * Internal mime part * * @var array */ protected $part = array();
/** * Immutable Part Id * * @var string */ private $id;
/** * Create a mime part * * @param array $part * @param string $id */ public function __construct($id, array $part) { $this->part = $part; $this->id = $id; }
/** * Retrieve the part Id * * @return string */ public function getId() { return $this->id; }
/** * Retrieve the part data * * @return array */ public function getPart() { return $this->part; }
/** * Set the mime part data * * @param array $part * @return void */ public function setPart(array $part) { $this->part = $part; }
/** * ArrayAccess */ #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { $this->part[] = $value; return; } $this->part[$offset] = $value; }
/** * ArrayAccess */ #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->part[$offset]); }
/** * ArrayAccess */ #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->part[$offset]); }
/** * ArrayAccess */ #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->part[$offset]) ? $this->part[$offset] : null; }}