public function testToCamelCase()
 {
     // Initialize
     $sInput = 'test_camel_case';
     // Assert
     $this->assertEquals('testCamelCase', ExtendedString::toCamelCase($sInput));
 }
 public function getRepository($sRepositoryName, $sNamespace)
 {
     if (empty($this->aRepositories[$sRepositoryName])) {
         // Get class name
         $sClassName = sprintf('\\%1$s\\Repository\\%2$s', $sNamespace === '' ? $this->sNamespace : $sNamespace, ExtendedString::toCamelCase($sRepositoryName, '_', true));
         // Check class exists
         if (!class_exists($sClassName)) {
             throw new RuntimeException(sprintf('Invalid class name %s', $sClassName));
         }
         // Create repository
         $this->aRepositories[$sRepositoryName] = new $sClassName($this->oMapperFactory->getMapper($sRepositoryName));
     }
     return $this->aRepositories[$sRepositoryName];
 }
Esempio n. 3
0
 public function getMapper($sMapperName, $sNamespace = '')
 {
     if (empty($this->aMappers[$sMapperName])) {
         // Get class name
         $sClassName = sprintf('\\%1$s\\Mapper\\%2$s', $sNamespace === '' ? $this->sNamespace : $sNamespace, ExtendedString::toCamelCase($sMapperName, '_', true));
         // Check class exists
         if (!class_exists($sClassName)) {
             throw new RuntimeException(sprintf('Invalid class name %s', $sClassName));
         }
         // Create mapper
         $this->aMappers[$sMapperName] = new $sClassName($this->oDbConnectionLocator->getWrite(ExtendedString::toSnakeCase(explode('\\', $sMapperName)[0], '_', true)));
     }
     return $this->aMappers[$sMapperName];
 }
Esempio n. 4
0
 public function addHandler($sHandlerName, $sClassName, array $aConfig, $bDefaultHandler = false, $sNamespace = '')
 {
     // Get class name
     $sClassName = ExtendedString::toCamelCase(sprintf('%s\\%sHandler', $sNamespace === '' ? $this->sNamespace : $sNamespace, $sClassName), '_', true);
     // Class name is valid
     if (!class_exists($sClassName)) {
         throw new RuntimeException(sprintf('Invalid class name %s', $sClassName));
     }
     // Add handler
     /** @var $oHandler \Asticode\FileManager\Handler\HandlerInterface */
     $oHandler = new $sClassName($aConfig);
     $this->aHandlers[$sHandlerName] = $oHandler;
     // Default handler
     if ($bDefaultHandler) {
         $this->sDefaultHandlerName = $sHandlerName;
     }
     // Add file methods
     $this->aCopyMethods = array_merge($this->aCopyMethods, $oHandler->getCopyMethods());
     $this->aMoveMethods = array_merge($this->aMoveMethods, $oHandler->getMoveMethods());
 }
 /**
  * @param $sHandlerName
  * @return \Asticode\DeploymentManager\Service\Build\Handler\HandlerInterface
  */
 private function getHandler($sHandlerName)
 {
     if (empty($this->aHandlers[$sHandlerName])) {
         // Get class name
         $sClassName = sprintf('\\Asticode\\DeploymentManager\\Service\\Build\\Handler\\%1$sHandler', ExtendedString::toCamelCase($sHandlerName, '_', true));
         // Check class exists
         if (!class_exists($sClassName)) {
             throw new RuntimeException(sprintf('Invalid class name %s', $sClassName));
         }
         // Create handler
         $oHandler = new $sClassName($this->oFileManager, $this->aConfig);
         // Handler implements the interface
         if (!$oHandler instanceof HandlerInterface) {
             throw new RuntimeException(sprintf('Class name %s doesn\'t implement the HandlerInterface', $sClassName));
         }
         // Add handler
         $this->aHandlers[$sHandlerName] = $oHandler;
     }
     return $this->aHandlers[$sHandlerName];
 }
 /**
  * @param $sHandlerName
  * @param $sClassName
  * @param $iPriority
  * @param array $aConfig
  * @param string $sNamespace
  * @return CacheManager
  */
 public function addHandler($sHandlerName, $sClassName, $iPriority, array $aConfig, $sNamespace = '')
 {
     // Get class name
     $sClassName = ExtendedString::toCamelCase(sprintf('%s\\%sHandler', $sNamespace === '' ? $this->sNamespace : $sNamespace, $sClassName), '_', true);
     // Class name is valid
     if (!class_exists($sClassName)) {
         throw new RuntimeException(sprintf('Invalid class name %s', $sClassName));
     }
     // Priority is valid
     $iPriority = intval($iPriority);
     if (array_key_exists($iPriority, $this->aPriorityToNameMapping)) {
         throw new RuntimeException(sprintf('Priority %s is already in use', $iPriority));
     }
     // Add handler
     $oHandler = new $sClassName($aConfig);
     $this->aHandlers[$sHandlerName] = $oHandler;
     // Add priority
     $this->aPriorityToNameMapping[$iPriority] = $sHandlerName;
     ksort($this->aPriorityToNameMapping);
     // Return
     return $this;
 }