refactor: use unified service provider desing

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-06-25 23:47:17 -04:00
parent 87d6af93b7
commit 6ca83a7dd7
19 changed files with 198 additions and 135 deletions
@@ -10,36 +10,27 @@ declare(strict_types=1);
namespace KTXF\Chrono\Provider;
use KTXF\Chrono\Service\ServiceBaseInterface;
use KTXF\Chrono\Service\ServiceMutableInterface;
/**
* Chrono Provider Service Test Interface
* Provider Service Test Interface
*
* Optional interface for chrono providers that support testing service connections.
* Providers implementing this interface can validate connection parameters,
* test authentication, and verify service availability before creating a
* persistent service configuration.
*
* Supports two testing modes:
* 1. Testing an existing service (validate current configuration)
* 2. Testing a fresh configuration (validate before saving)
* Optional interface for providers that support testing service connections
*
* @since 2025.05.01
*/
interface ProviderServiceTestInterface extends ProviderBaseInterface {
interface ProviderServiceTestInterface {
public const CAPABILITY_SERVICE_TEST = 'ServiceTest';
/**
* Test a service connection
*
* Tests connectivity, authentication, and capabilities of a service.
*
* For new services: use serviceFresh() to create a service, configure it with
* setters, then pass it to this method for testing before persisting.
*
* For existing services: fetch the service and pass it directly.
* Tests connectivity, authentication, and capabilities of a service
*
* @since 2025.05.01
*
* @param ServiceBaseInterface $service Service to test (can be fresh/unsaved or existing)
* @param ServiceBaseInterface|ServiceMutableInterface $service Service to test (can be fresh/unsaved or existing)
* @param array $options Provider-specific test options:
* - 'timeout' => int (seconds, default: 10)
* - 'verify_ssl' => bool (default: true)
@@ -48,10 +39,10 @@ interface ProviderServiceTestInterface extends ProviderBaseInterface {
*
* @return array Test results in the format:
* [
* 'success' => bool,
* 'message' => 'Connection successful' | 'Error message'
* 'disposition' => 'Success' | 'Failure' | 'Warning',
* 'message' => 'Connection successful' | 'Error message',
* ]
*/
public function serviceTest(ServiceBaseInterface $service, array $options = []): array;
public function serviceTest(ServiceBaseInterface|ServiceMutableInterface $service, array $options = []): array;
}