/** * Gets all classes based on passed type, instantiates * them and stores them under $objects using * underscored keys * * @param string $type * @param \LewNelson\Namecheap\Connect\Connect $connection * @param array $configuration */ public function __construct($type, $connection, $configuration) { $this->configuration = $configuration; $prefix = 'LewNelson/Namecheap/Objects/' . $type; $classes = Utilities::getClasses(__DIR__ . '/' . $type, $prefix); foreach ($classes as $class) { $full_namespace = Utilities::getFullNamespace($class); $object = new $full_namespace($configuration); $name = str_replace($prefix, '', $class); $name = Utilities::convertCamelCaseToUnderscore($name); $this->set($object, $name); } $this->setConnections($connection); }
/** * Set up the object with properties to access all * method_type objects * * @param array $config * @throws \Exception if $config not array */ public function __construct($config) { if (!is_array($config)) { throw new \Exception('Invalid config, expecting array', 1); } else { if (empty($config)) { throw new \Exception('Cannot pass empty configuration array', 2); } } $prefix = 'LewNelson/Namecheap/MethodTypes'; $method_types = Utilities::getClasses(__DIR__ . '/MethodTypes', $prefix); foreach ($method_types as $method_type) { $object = $this->create($method_type, $config); $method_type = str_replace($prefix, '', $method_type); $this->setMethodType($object, $method_type); } }