Skip to content
Snippets Groups Projects
Commit 27a3b72e authored by Nigel  Sahl's avatar Nigel Sahl
Browse files

Create ApiKeyHandler.php

parent ccf208ee
Branches
Tags
No related merge requests found
<?php
class ApiKeyHandler
{
private static $instance;
private $apiKey;
private function __construct()
{
$this->apiKey = $_ENV['API_KEY'];
}
/**
* @return ApiKeyHandler
*/
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new static();
}
return self::$instance;
}
public function checkApiKey($apiKeyHeader)
{
$res = $this->apiKey === $apiKeyHeader;
// if (!$res) {
// throw new Exception('Invalid API Key');
// }
return $res;
}
}
?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment