generated from Nodarx/template
feat: initial version
Signed-off-by: Sebastian Krupinski <root@LAPTOP-7DVOR6NC>
This commit was merged in pull request #1.
This commit is contained in:
36
lib/Client/Protocol/Command/Argument/SequenceSet.php
Normal file
36
lib/Client/Protocol/Command/Argument/SequenceSet.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Gricob\IMAP\Protocol\Command\Argument;
|
||||
|
||||
final class SequenceSet implements Argument
|
||||
{
|
||||
/**
|
||||
* @var array<int>
|
||||
*/
|
||||
private array $numbers;
|
||||
private ?string $range;
|
||||
|
||||
public function __construct(int ...$numbers)
|
||||
{
|
||||
$this->numbers = $numbers;
|
||||
$this->range = null;
|
||||
}
|
||||
|
||||
public static function range(int $from, int $to): self
|
||||
{
|
||||
$set = new self();
|
||||
$set->range = $from . ':' . $to;
|
||||
return $set;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->range !== null) {
|
||||
return $this->range;
|
||||
}
|
||||
|
||||
return implode(',', $this->numbers);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user