ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
class.ilLTIHttpClient.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ceLTIc\LTI\Http\ClientInterface;
22use ceLTIc\LTI\Http\HttpMessage;
23
30final readonly class ilLTIHttpClient implements ClientInterface
31{
32 public function __construct(private ?ClientInterface $client, private ilLogger $logger)
33 {
34 }
35
36 public function send(HttpMessage $message): bool
37 {
38 if ($this->client === null) {
39 $this->logger->error('LTI call {method} {url} not sent: PHP has neither cURL nor allow_url_fopen', [
40 'method' => $message->getMethod(),
41 'url' => ilLTILibraryLogger::hideSecrets($message->getUrl()),
42 ]);
43 return false;
44 }
45
46 $start = hrtime(true);
47 $ok = $this->client->send($message);
48 $this->logger->debug('LTI call {method} {url}: {status} in {ms} ms{error}', [
49 'method' => $message->getMethod(),
50 'url' => ilLTILibraryLogger::hideSecrets($message->getUrl()),
51 'status' => $message->status,
52 'ms' => intdiv(hrtime(true) - $start, 1_000_000),
53 'error' => $message->error !== '' ? ', ' . $message->error : '',
54 ]);
55
56 return $ok;
57 }
58}
The HTTP client of celtic/lti, which logs how each call of ILIAS to a platform or a tool ended and ho...
__construct(private ?ClientInterface $client, private ilLogger $logger)
send(HttpMessage $message)
static hideSecrets(string $message)
The message without the secrets it may hold.
Component logger with individual log levels by component id.
$client