Passed
Push — master ( 35232d...8d0b59 )
by Melech
06:16 queued 02:04
created

LogClient::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Valkyrja Framework package.
7
 *
8
 * (c) Melech Mizrachi <[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 Valkyrja\Http\Client;
15
16
use JsonException;
17
use Valkyrja\Http\Client\Contract\Client as Contract;
18
use Valkyrja\Http\Message\Factory\Contract\ResponseFactory;
19
use Valkyrja\Http\Message\Request\Contract\Request;
20
use Valkyrja\Http\Message\Response\Contract\Response;
21
use Valkyrja\Log\Contract\Logger;
22
use Valkyrja\Type\BuiltIn\Support\Obj;
23
24
/**
25
 * Class LogClient.
26
 *
27
 * @author Melech Mizrachi
28
 */
29
class LogClient implements Contract
30
{
31
    public function __construct(
32
        protected Logger $logger,
33
        protected ResponseFactory $responseFactory,
34
    ) {
35
    }
36
37
    /**
38
     * @inheritDoc
39
     *
40
     * @throws JsonException
41
     */
42
    public function sendRequest(Request $request): Response
43
    {
44
        $optionsString = Obj::toString($request);
45
46
        $this->logger->info(
47
            static::class . " request: {$request->getMethod()->value}, uri {$request->getUri()->__toString()}, options $optionsString"
48
        );
49
50
        return $this->responseFactory->createResponse();
51
    }
52
}
53