getResponseTransformer() public method

Gets the responsetransformerclass
public getResponseTransformer ( ) : ApaiIO\ResponseTransformer\ResponseTransformerInterface
return ApaiIO\ResponseTransformer\ResponseTransformerInterface
Ejemplo n.º 1
0
 /**
  * Applies a responsetransformer.
  *
  * @param mixed $response The response of the request
  *
  * @return mixed
  */
 protected function applyResponseTransformer($response)
 {
     if (null === ($responseTransformer = $this->configuration->getResponseTransformer())) {
         return $response;
     }
     return $responseTransformer->transform($response);
 }
Ejemplo n.º 2
0
 /**
  * Applies a responsetransformer
  *
  * @param mixed                  $response      The response of the request
  * @param ConfigurationInterface $configuration The configurationobject
  *
  * @return mixed
  */
 protected function applyResponseTransformer($response, ConfigurationInterface $configuration)
 {
     if (true === is_null($configuration->getResponseTransformer())) {
         return $response;
     }
     $responseTransformer = ResponseTransformerFactory::createResponseTransformer($configuration);
     return $responseTransformer->transform($response);
 }
 /**
  * Creates a new ResponseTransformer-object
  *
  * @param ConfigurationInterface $configuration
  *
  * @return \ApaiIO\ResponseTransformer\ResponseTransformerInterface
  */
 public static function createResponseTransformer(ConfigurationInterface $configuration)
 {
     $class = $configuration->getResponseTransformer();
     $factoryCallback = $configuration->getResponseTransformerFactory();
     if (true === is_object($class) && $class instanceof \ApaiIO\ResponseTransformer\ResponseTransformerInterface) {
         return self::applyCallback($factoryCallback, $class);
     }
     if (true === is_string($class) && true === array_key_exists($class, self::$responseTransformerObjects)) {
         return self::applyCallback($factoryCallback, self::$responseTransformerObjects[$class]);
     }
     try {
         $reflectionClass = new \ReflectionClass($class);
     } catch (\ReflectionException $e) {
         throw new \InvalidArgumentException(sprintf("Responsetransformerclass not found: %s", $class));
     }
     if ($reflectionClass->implementsInterface('\\ApaiIO\\ResponseTransformer\\ResponseTransformerInterface')) {
         $responseTransformer = new $class();
         return self::$responseTransformerObjects[$class] = self::applyCallback($factoryCallback, $responseTransformer);
     }
     throw new \LogicException(sprintf("Responsetransformerclass does not implements the ResponseTransformerInterface: %s", $class));
 }