/** * Builds method type object * * @param string $method_type where namespacing uses / rather than \ * @param array $config * @throws \Exception if class cannot be found * * @return instance of a class implementing NamecheapMethodTypesInterface */ private function create($method_type, $config) { $class_string = $method_type; $namespaced_class = Utilities::getFullNamespace($class_string); $class = new $namespaced_class(); $object = $this->build($class, $config); return $object; }
/** * 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); }
/** * @dataProvider getFullNamespaceValidValuesProvider */ public function testGetFullNamespaceWithValidData($data, $expected_output) { $output = Utilities::getFullNamespace($data); $this->assertEquals($output, $expected_output); }