diff --git a/composer.json b/composer.json index 626cf3b..9d0920e 100644 --- a/composer.json +++ b/composer.json @@ -8,8 +8,7 @@ }, "require": { "php": ">=8.1", - "guzzlehttp/guzzle": "^7.8", - "visus/cuid2": "^3.0 || ^4.1" + "guzzlehttp/guzzle": "^7.8" }, "scripts": { "test": "vendor/bin/pest" diff --git a/src/Client.php b/src/Client.php index ae13aab..ac56494 100644 --- a/src/Client.php +++ b/src/Client.php @@ -5,12 +5,13 @@ use GuzzleHttp\Client as HttpClient; use OramaCloud\Client\Query; use OramaCloud\Telemetry\Collector; +use OramaCloud\Traits\GeneratesUniqueId; use OramaCloud\Traits\ValidatesParams; -use Visus\Cuid2\Cuid2; class Client { use ValidatesParams; + use GeneratesUniqueId; private $answersApiBaseURL; private $apiKey; @@ -28,7 +29,7 @@ public function __construct(array $params, HttpClient $http = null) 'answersApiBaseURL' => ['optional', 'string'] ]); - $this->id = (new Cuid2())->toString(); + $this->id = $this->generateUniqueId(); $this->http = !is_null($http) ? $http : new HttpClient(); $this->apiKey = $params['api_key']; $this->endpoint = $params['endpoint']; @@ -74,11 +75,6 @@ public function search(Query $query) return $results; } - public function getCollector(): Collector|null - { - return $this->collector; - } - private function init() { $response = $this->fetch('init', 'POST'); diff --git a/src/Telemetry/Collector.php b/src/Telemetry/Collector.php index 4df89cb..5ce5791 100644 --- a/src/Telemetry/Collector.php +++ b/src/Telemetry/Collector.php @@ -3,7 +3,6 @@ namespace OramaCloud\Telemetry; use GuzzleHttp\Client; -use GuzzleHttp\Promise\PromiseInterface; class Collector { @@ -78,7 +77,7 @@ private function start() $this->flush(); } - private function sendBeacon($body): PromiseInterface|null + private function sendBeacon($body) { if ($this->params == null || !isset($this->params['endpoint'])) { return null; diff --git a/src/Traits/GeneratesUniqueId.php b/src/Traits/GeneratesUniqueId.php new file mode 100644 index 0000000..6c44c32 --- /dev/null +++ b/src/Traits/GeneratesUniqueId.php @@ -0,0 +1,11 @@ +