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

vjik / telegram-bot-api / 18555779747

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

Pull #167

github

web-flow
Merge fea52bd4d 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/WebhookResponse.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Vjik\TelegramBot\Api\WebhookResponse;
6

7
use Vjik\TelegramBot\Api\MethodInterface;
8
use Vjik\TelegramBot\Api\Type\InputFile;
9

10
/**
11
 * @api
12
 */
13
final readonly class WebhookResponse
14
{
15
    private string $apiMethod;
16
    private array $apiData;
17

NEW
18
    public function __construct(MethodInterface $method)
×
19
    {
NEW
20
        $this->apiMethod = $method->getApiMethod();
×
NEW
21
        $this->apiData = $method->getData();
×
22
    }
23

24
    /**
25
     * @throws MethodNotSupportedException If method doesn't support sending via a webhook response.
26
     */
NEW
27
    public function getData(): array
×
28
    {
NEW
29
        $this->assertSupport();
×
30

NEW
31
        return [
×
NEW
32
            'method' => $this->apiMethod,
×
NEW
33
            ...$this->apiData,
×
NEW
34
        ];
×
35
    }
36

NEW
37
    public function isSupported(): bool
×
38
    {
39
        try {
NEW
40
            $this->assertSupport();
×
NEW
41
            return true;
×
NEW
42
        } catch (MethodNotSupportedException) {
×
NEW
43
            return false;
×
44
        }
45
    }
46

47
    /**
48
     * @throws MethodNotSupportedException If {@see InputFile} is used in method data.
49
     */
NEW
50
    private function assertSupport(): void
×
51
    {
NEW
52
        foreach ($this->apiData as $value) {
×
NEW
53
            if ($value instanceof InputFile) {
×
NEW
54
                throw new MethodNotSupportedException('InputFile is not supported in Webhook response.');
×
55
            }
56
        }
57
    }
58
}
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