ConfigurationMiddleware   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 7 2
1
<?php
2
/**
3
 * BEdita, API-first content management framework
4
 * Copyright 2022 ChannelWeb Srl, Chialab Srl
5
 *
6
 * This file is part of BEdita: you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser General Public License as published
8
 * by the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * See LICENSE.LGPL or <http://gnu.org/licenses/lgpl-3.0.html> for more details.
12
 */
13
namespace App\Middleware;
14
15
use App\Utility\ApiConfigTrait;
16
use Cake\Core\Configure;
17
use Psr\Http\Message\ResponseInterface;
18
use Psr\Http\Message\ServerRequestInterface;
19
use Psr\Http\Server\MiddlewareInterface;
20
use Psr\Http\Server\RequestHandlerInterface;
21
22
/**
23
 * Configuration middleware.
24
 *
25
 * Load configuration from API using cache.
26
 */
27
class ConfigurationMiddleware implements MiddlewareInterface
28
{
29
    use ApiConfigTrait;
30
31
    /**
32
     * @inheritDoc
33
     */
34
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
35
    {
36
        if (Configure::check('API.apiBaseUrl')) {
37
            $this->readApiConfig();
38
        }
39
40
        return $handler->handle($request);
41
    }
42
}
43