diff --git a/src/APIlite.php b/src/APIlite.php index ac37138..712bf8b 100644 --- a/src/APIlite.php +++ b/src/APIlite.php @@ -21,10 +21,11 @@ class APIlite private string $endpoint = ''; private $methods = array(); - public function __construct(?string $format = null, ?string $endpoint = null) + public function __construct(?string $format = null, ?string $endpoint = null, ?string $apiName = null) { register_shutdown_function(array($this, '_shutdownHandler')); $this->endpoint = $endpoint ?? $this->getCurrentUrl(); + $this->apiName = $apiName ?? ''; $this->analyzeClass(); if (isset($_REQUEST['action'])) { $this->doAction($_REQUEST['action']); @@ -67,7 +68,9 @@ class APIlite private function analyzeClass(): bool { $refClass = new \ReflectionClass($this); - $this->apiName = $refClass->getShortName(); + if (strlen($this->apiName) <= 0) { + $this->apiName = $refClass->getShortName(); + } $this->methods = array(); foreach ($refClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $ref_method) { $method_name = $ref_method->getName();