Issues (18)

Business/Exception/Renderer/RendererFactory.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Plugin\Http\Business\Exception\Renderer;
15
16
use Micro\Plugin\Http\Configuration\HttpExceptionResponseDevPluginConfigurationInterface;
17
use Symfony\Component\HttpFoundation\Request;
18
19
/**
20
 * @author Stanislau Komar <[email protected]>
21
 */
22
readonly class RendererFactory implements RendererFactoryInterface
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_READONLY on line 22 at column 0
Loading history...
23
{
24 33
    public function __construct(
25
        private HttpExceptionResponseDevPluginConfigurationInterface $pluginConfiguration
26
    ) {
27 33
    }
28
29 18
    public function create(Request $request): RendererInterface
30
    {
31 18
        $format = $request->get('_format');
32
33
        switch ($format) {
34 18
            case 'json':
35 8
                return new JsonRenderer();
36
            default:
37 10
                return new HtmlRenderer(
38 10
                    $this->pluginConfiguration->getProjectDir(),
39 10
                );
40
        }
41
    }
42
}
43