diff --git a/lib/Factory/FactoryBase.php b/lib/Factory/Base.php similarity index 67% rename from lib/Factory/FactoryBase.php rename to lib/Factory/Base.php index 7b6a15ff..835ced5f 100644 --- a/lib/Factory/FactoryBase.php +++ b/lib/Factory/Base.php @@ -3,10 +3,11 @@ namespace HubSpot\Factory; use GuzzleHttp\Client; -use HubSpot\Client\Crm\Owners\Api\DefaultApi; use HubSpot\Client\Crm\Owners\Configuration; +use ReflectionClass; +use ReflectionException; -class FactoryBase +class Base { /** @var Client */ protected $client; @@ -24,11 +25,14 @@ public function __construct($client, $config) * @param string $name * @param mixed $args * + * @throws ReflectionException + * * @return mixed */ public function __call($name, $args) { - $resource = '\\HubSpot\\Client\\Crm\\'.ucfirst(get_class()).'\\Api\\'.ucfirst($name); + $className = (new ReflectionClass(get_class($this)))->getShortName(); + $resource = '\\HubSpot\\Client\\Crm\\'.$className.'\\Api\\'.ucfirst($name); return new $resource($this->client, $this->config); } diff --git a/lib/Factory/Objects.php b/lib/Factory/Objects.php index c3c92ae1..bc29497f 100644 --- a/lib/Factory/Objects.php +++ b/lib/Factory/Objects.php @@ -15,6 +15,6 @@ * @method CreateNativeObjectsApi createNativeObjectsApi * @method SearchApi searchApi() */ -class Objects extends FactoryBase +class Objects extends Base { } diff --git a/lib/Factory/Owners.php b/lib/Factory/Owners.php index 9f904819..c39740f9 100644 --- a/lib/Factory/Owners.php +++ b/lib/Factory/Owners.php @@ -7,6 +7,6 @@ /** * @method DefaultApi defaultApi() */ -class Owners extends FactoryBase +class Owners extends Base { }