public function __invoke($config)
 {
     if (getValue('in', $config) === null) {
         return $this->createFromArray((array) $config);
     }
     return $this->createFromConfig($config);
 }
 /**
  * Invoke middleware.
  *
  * @param ServerRequestInterface $request  request object
  * @param ResponseInterface      $response response object
  * @param callable               $next     next middleware
  *
  * @return ResponseInterface response object
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     $token = getValue($this->path, $request->getParsedBody(), null);
     if ($token === null) {
         return $next($request, $response);
     }
     $tokenViolations = call_user_func($this->tokenValidator, $token);
     if (count($tokenViolations) === 0) {
         return $next($request->withAttribute(self::$isValidAttribute, true), $response);
     }
     $violations = $request->getAttribute(self::$violationsAttribute, []);
     $violations = array_merge($violations, $tokenViolations);
     return $next($request->withAttribute(self::$violationsAttribute, $violations), $response);
 }
 /**
  * Get configuration value.
  *
  * @see https://github.com/schnittstabil/get Documentation of `Schnittstabil\Get\getValue`
  *
  * @param string|int|mixed[] $path    a `Schnittstabil\Get\getValue` path
  * @param mixed              $default default value if $path is not valid
  *
  * @return mixed the value determined by `$path` or otherwise `$default`
  */
 public function get($path = array(), $default = null)
 {
     return getValue($path, $this->getConfig(), $default);
 }