mirror of
https://github.com/retailcrm/transparent-email.git
synced 2024-11-22 05:16:05 +03:00
32 lines
758 B
PHP
32 lines
758 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace bkrukowski\TransparentEmail;
|
|
|
|
use bkrukowski\TransparentEmail\Emails\EmailInterface;
|
|
use bkrukowski\TransparentEmail\Services\ServiceInterface;
|
|
|
|
class TransparentEmail implements TransparentEmailInterface
|
|
{
|
|
/**
|
|
* @var ServiceCollectorInterface|ServiceInterface[]
|
|
*/
|
|
private $services;
|
|
|
|
public function __construct(ServiceCollectorInterface $services)
|
|
{
|
|
$this->services = $services;
|
|
}
|
|
|
|
public function getPrimaryEmail(EmailInterface $email) : EmailInterface
|
|
{
|
|
foreach ($this->services as $service) {
|
|
if ($service->isSupported($email)) {
|
|
return $service->getPrimaryEmail($email);
|
|
}
|
|
}
|
|
|
|
return $email;
|
|
}
|
|
} |