feat: initial version

Signed-off-by: Sebastian Krupinski <root@LAPTOP-7DVOR6NC>
This commit is contained in:
Sebastian Krupinski
2026-02-20 16:41:19 -05:00
commit 7f562d6aba
139 changed files with 11256 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Gricob\IMAP\Protocol\Response\Line\Data;
final readonly class CapabilityData implements Data
{
/**
* @param list<string> $capabilities
*/
public function __construct(public array $capabilities)
{
}
}

View File

@@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
namespace Gricob\IMAP\Protocol\Response\Line\Data;
use Gricob\IMAP\Protocol\Response\Line\Line;
interface Data extends Line
{
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace Gricob\IMAP\Protocol\Response\Line\Data;
final readonly class ExistsData implements Data
{
public function __construct(public int $numberOfMessages)
{
}
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace Gricob\IMAP\Protocol\Response\Line\Data;
final readonly class ExpungeData implements Data
{
public function __construct(public int $id)
{
}
}

View File

@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace Gricob\IMAP\Protocol\Response\Line\Data\Fetch;
final readonly class Address
{
public function __construct(
public ?string $displayName,
public ?string $atDomainList,
public ?string $mailboxName,
public ?string $hostName,
) {
}
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace Gricob\IMAP\Protocol\Response\Line\Data\Fetch;
final readonly class BodySection
{
public function __construct(public string $section, public string $text)
{
}
}

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Gricob\IMAP\Protocol\Response\Line\Data\Fetch;
use Gricob\IMAP\Protocol\Response\Line\Data\Fetch\BodyStructure\Part;
class BodyStructure
{
public function __construct(
public Part $part,
) {
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Gricob\IMAP\Protocol\Response\Line\Data\Fetch\BodyStructure;
final readonly class Disposition
{
/**
* @param array<string, string> $attributes
*/
public function __construct(
public string $type,
public array $attributes,
) {
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace Gricob\IMAP\Protocol\Response\Line\Data\Fetch\BodyStructure;
use Gricob\IMAP\Protocol\Response\Line\Data\Fetch\BodyStructure;
use Gricob\IMAP\Protocol\Response\Line\Data\Fetch\Envelope;
readonly class MessagePart extends SinglePart
{
/**
* @param array<string, string> $attributes
* @param string[]|null $language
*/
public function __construct(
array $attributes,
?string $id,
?string $description,
string $encoding,
int $size,
public Envelope $envelope,
public BodyStructure $bodyStructure,
public int $textLines,
?string $md5,
?Disposition $disposition,
?array $language,
?string $location,
) {
parent::__construct(
'MESSAGE',
'RFC822',
$attributes,
$id,
$description,
$encoding,
$size,
$md5,
$disposition,
$language,
$location,
);
}
}

View File

@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace Gricob\IMAP\Protocol\Response\Line\Data\Fetch\BodyStructure;
final readonly class MultiPart extends Part
{
/**
* @param array<string,string> $attributes
* @param string[] $language
* @param list<Part> $parts
*/
public function __construct(
string $subtype,
array $attributes,
public array $parts,
public ?Disposition $disposition,
public ?array $language,
public ?string $location,
) {
parent::__construct('MULTIPART', $subtype, $attributes);
}
}

View File

@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace Gricob\IMAP\Protocol\Response\Line\Data\Fetch\BodyStructure;
abstract readonly class Part
{
/**
* @param array<string,string> $attributes
*/
public function __construct(
public string $type,
public string $subtype,
public array $attributes,
) {
}
}

View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace Gricob\IMAP\Protocol\Response\Line\Data\Fetch\BodyStructure;
readonly class SinglePart extends Part
{
/**
* @param array<string,string> $attributes
* @param string[]|null $language
*/
public function __construct(
string $type,
string $subtype,
array $attributes,
public ?string $id,
public ?string $description,
public string $encoding,
public int $size,
public ?string $md5,
public ?Disposition $disposition,
public ?array $language,
public ?string $location,
) {
parent::__construct($type, $subtype, $attributes);
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Gricob\IMAP\Protocol\Response\Line\Data\Fetch\BodyStructure;
final readonly class TextPart extends SinglePart
{
/**
* @param array<string, string> $attributes
* @param string[]|null $language
*/
public function __construct(
string $subtype,
array $attributes,
?string $id,
?string $description,
string $encoding,
int $size,
public int $textLines,
?string $md5,
?Disposition $disposition,
?array $language,
?string $location,
) {
parent::__construct(
'TEXT',
$subtype,
$attributes,
$id,
$description,
$encoding,
$size,
$md5,
$disposition,
$language,
$location,
);
}
}

View File

@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Gricob\IMAP\Protocol\Response\Line\Data\Fetch;
use DateTimeImmutable;
final readonly class Envelope
{
/**
* @param Address[]|null $from
* @param Address[]|null $sender
* @param Address[]|null $replyTo
* @param Address[]|null $to
* @param Address[]|null $cc
* @param Address[]|null $bcc
*/
public function __construct(
public ?DateTimeImmutable $date,
public ?string $subject,
public ?array $from,
public ?array $sender,
public ?array $replyTo,
public ?array $to,
public ?array $cc,
public ?array $bcc,
public ?string $inReplyTo,
public ?string $messageId,
) {
}
}

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace Gricob\IMAP\Protocol\Response\Line\Data;
use Gricob\IMAP\Protocol\Response\Line\Data\Fetch\BodySection;
use Gricob\IMAP\Protocol\Response\Line\Data\Fetch\BodyStructure;
use Gricob\IMAP\Protocol\Response\Line\Data\Fetch\Envelope;
final readonly class FetchData implements Data
{
/**
* @param array<string>|null $flags
* @param BodySection[] $bodySections
*/
public function __construct(
public int $id,
public ?array $flags = null,
public ?\DateTimeImmutable $internalDate = null,
public ?Envelope $envelope = null,
public ?int $rfc822Size = null,
public ?string $rfc822 = null,
public ?int $uid = null,
public ?BodyStructure $bodyStructure = null,
public array $bodySections = [],
) {
}
public function getBodySection(string $name): ?BodySection
{
foreach (($this->bodySections ?? []) as $bodySection) {
if ($bodySection->section == $name) {
return $bodySection;
}
}
return null;
}
}

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Gricob\IMAP\Protocol\Response\Line\Data;
final readonly class FlagsData implements Data
{
/**
* @param list<string> $flags
*/
public function __construct(public array $flags)
{
}
}

View File

@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace Gricob\IMAP\Protocol\Response\Line\Data;
final class ListData implements Data
{
/**
* @param list<string> $nameAttributes
*/
public function __construct(
public array $nameAttributes,
public string $hierarchyDelimiter,
public string $name
) {
}
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace Gricob\IMAP\Protocol\Response\Line\Data;
final class RecentData implements Data
{
public function __construct(public int $numberOfMessages)
{
}
}

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Gricob\IMAP\Protocol\Response\Line\Data;
final readonly class SearchData implements Data
{
/**
* @param list<int> $numbers
*/
public function __construct(public array $numbers)
{
}
}