1) { $scope = ""; foreach ($composedScope as $word) { $scope .= ucfirst($word); } $serviceScope = $scope; } if (is_string($namespace)) { $scope = sprintf("%s\%s", ucfirst($namespace), ucfirst($serviceScope)); } $className = sprintf( "\Alchemy\Phrasea\Core\Service\%s\%s" , ucfirst($serviceScope) , ucfirst($serviceType) ); if (class_exists($className)) { return new $className($serviceName, $options); } else { throw new \Exception(sprintf( 'Unknow service %s for %s scopes looked for classname %s' , str_replace('/', '_', $serviceType) , $serviceScope , $className) ); } } }