for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Genkgo\Mail\Protocol\Imap;
final class ParenthesizedList
{
/**
* @var array<string, string>
*/
private $list = [];
* @param array<string, string> $list
public function __construct(array $list = [])
$this->list = $list;
}
* @param string $name
* @return ParenthesizedList
public function with(string $name): self
$clone = clone $this;
$clone->list[$name] = $name;
return $clone;
public function without(string $name): self
unset($clone->list[$name]);
* @return string
public function __toString(): string
if (empty($this->list)) {
return '';
return \sprintf(
'(%s)',
\implode(' ', $this->list)
);