generated from Nodarx/template
refactor: split service into ServiceBase and LiveService
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
+10
-10
@@ -106,7 +106,7 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface,
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function serviceFetch(string $tenantId, string $userId, string|int $identifier): ?Service
|
||||
public function serviceFetch(string $tenantId, string $userId, string|int $identifier): ?ServiceBase
|
||||
{
|
||||
$serviceData = $this->serviceStore->fetch($tenantId, $userId, $identifier);
|
||||
if ($serviceData === null) {
|
||||
@@ -116,9 +116,9 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface,
|
||||
return $serviceInstance;
|
||||
}
|
||||
|
||||
public function serviceFindByAddress(string $tenantId, string $userId, string $address): ?Service
|
||||
public function serviceFindByAddress(string $tenantId, string $userId, string $address): ?ServiceBase
|
||||
{
|
||||
/** @var Service[] $services */
|
||||
/** @var ServiceBase[] $services */
|
||||
$services = $this->serviceList($tenantId, $userId);
|
||||
foreach ($services as $service) {
|
||||
if ($service->hasAddress($address)) {
|
||||
@@ -133,14 +133,14 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface,
|
||||
return $this->serviceStore->extant($tenantId, $userId, $identifiers);
|
||||
}
|
||||
|
||||
public function serviceFresh(): Service
|
||||
public function serviceFresh(): ServiceBase
|
||||
{
|
||||
return new Service();
|
||||
return new LiveService();
|
||||
}
|
||||
|
||||
public function serviceCreate(string $tenantId, string $userId, ResourceServiceMutateInterface $service): string
|
||||
{
|
||||
if (!($service instanceof Service)) {
|
||||
if (!($service instanceof ServiceBase)) {
|
||||
throw new \InvalidArgumentException('Service must be instance of IMAP Service');
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface,
|
||||
|
||||
public function serviceModify(string $tenantId, string $userId, ResourceServiceMutateInterface $service): string
|
||||
{
|
||||
if (!($service instanceof Service)) {
|
||||
if (!($service instanceof ServiceBase)) {
|
||||
throw new \InvalidArgumentException('Service must be instance of IMAP Service');
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface,
|
||||
|
||||
public function serviceDestroy(string $tenantId, string $userId, ResourceServiceMutateInterface $service): bool
|
||||
{
|
||||
if (!($service instanceof Service)) {
|
||||
if (!($service instanceof ServiceBase)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface,
|
||||
$startTime = microtime(true);
|
||||
|
||||
try {
|
||||
if (!($service instanceof Service)) {
|
||||
if (!($service instanceof ServiceBase)) {
|
||||
throw new \InvalidArgumentException('Service must be an instance of IMAP Service');
|
||||
}
|
||||
// augment the service with any provided test options (e.g. override location or credentials)
|
||||
@@ -193,7 +193,7 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface,
|
||||
|
||||
// Attempt to authenticate and list mailboxes as a connectivity check
|
||||
$live = new LiveMailService($service);
|
||||
$mailboxes = iterator_to_array($live->collectionList());
|
||||
$mailboxes = $live->collectionList();
|
||||
|
||||
$latency = (int) round((microtime(true) - $startTime) * 1000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user