| 1 |
<?php |
| 2 |
/** |
| 3 |
* NullDriver — safe no-op telemetry driver |
| 4 |
* |
| 5 |
* Used when no telemetry driver is configured. All send operations silently |
| 6 |
* succeed without transmitting data, allowing the client to remain operational. |
| 7 |
* |
| 8 |
* @package LinnoSDK\Telemetry\Drivers |
| 9 |
* @since 1.0.0 |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace LinnoSDK\Telemetry\Drivers; |
| 13 |
|
| 14 |
/** |
| 15 |
* Class NullDriver |
| 16 |
* |
| 17 |
* A do-nothing driver that satisfies the DriverInterface contract without |
| 18 |
* transmitting any data. The warning about a missing driver is logged by the |
| 19 |
* Client before it creates a NullDriver instance. |
| 20 |
* |
| 21 |
* @since 1.0.0 |
| 22 |
*/ |
| 23 |
class NullDriver implements DriverInterface { |
| 24 |
|
| 25 |
/** |
| 26 |
* API key placeholder — not used by this driver. |
| 27 |
* |
| 28 |
* @var string |
| 29 |
*/ |
| 30 |
private string $apiKey = ''; |
| 31 |
|
| 32 |
/** |
| 33 |
* Always returns true (no-op send). |
| 34 |
* |
| 35 |
* @param string $event Event name. |
| 36 |
* @param array $properties Event properties. |
| 37 |
* @return bool Always true. |
| 38 |
*/ |
| 39 |
public function send( string $event, array $properties ): bool { |
| 40 |
return true; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Accept an API key — stored but never used. |
| 45 |
* |
| 46 |
* @param string $apiKey The API key. |
| 47 |
* @return void |
| 48 |
*/ |
| 49 |
public function setApiKey( string $apiKey ): void { |
| 50 |
$this->apiKey = $apiKey; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Always returns null — no errors can occur in a no-op driver. |
| 55 |
* |
| 56 |
* @return string|null |
| 57 |
*/ |
| 58 |
public function getLastError(): ?string { |
| 59 |
return null; |
| 60 |
} |
| 61 |
} |
| 62 |
|