• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vjik / telegram-bot-api / 18555831557

16 Oct 2025 08:54AM UTC coverage: 99.481% (-0.5%) from 100.0%
18555831557

Pull #167

github

web-flow
Merge ce82b2b9b into e5d621537
Pull Request #167: Add webhook response factories

0 of 35 new or added lines in 3 files covered. (0.0%)

6713 of 6748 relevant lines covered (99.48%)

28.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/WebhookResponse/PsrWebhookResponseFactory.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Vjik\TelegramBot\Api\WebhookResponse;
6

7
use Psr\Http\Message\ResponseFactoryInterface;
8
use Psr\Http\Message\ResponseInterface;
9
use Psr\Http\Message\StreamFactoryInterface;
10
use Vjik\TelegramBot\Api\MethodInterface;
11

12
use function json_encode;
13

14
/**
15
 * @api
16
 */
17
final readonly class PsrWebhookResponseFactory
18
{
NEW
19
    public function __construct(
×
20
        private ResponseFactoryInterface $responseFactory,
21
        private StreamFactoryInterface $streamFactory,
NEW
22
    ) {}
×
23

24
    /**
25
     * @throws MethodNotSupportedException If method doesn't support sending via a webhook response.
26
     */
NEW
27
    public function create(WebhookResponse $webhookResponse): ResponseInterface
×
28
    {
NEW
29
        $body = $this->streamFactory->createStream(
×
NEW
30
            json_encode($webhookResponse->getData(), JSON_THROW_ON_ERROR),
×
NEW
31
        );
×
32

NEW
33
        return $this->responseFactory
×
NEW
34
            ->createResponse()
×
NEW
35
            ->withBody($body)
×
NEW
36
            ->withHeader('Content-Type', 'application/json; charset=utf-8')
×
NEW
37
            ->withHeader('Content-Length', (string) $body->getSize());
×
38
    }
39

40
    /**
41
     * @throws MethodNotSupportedException If method doesn't support sending via a webhook response.
42
     */
NEW
43
    public function byMethod(MethodInterface $method): ResponseInterface
×
44
    {
NEW
45
        return $this->create(new WebhookResponse($method));
×
46
    }
47
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc