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

gammerce / sklep-sms / 30296431841

27 Jul 2026 06:51PM UTC coverage: 82.353% (-0.01%) from 82.367%
30296431841

push

github

web-flow
Support PHP 8.4, 8.5, 8.6

60 of 89 new or added lines in 59 files covered. (67.42%)

11909 of 14461 relevant lines covered (82.35%)

36.17 hits per line

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

4.55
/includes/Requesting/Requester.php
1
<?php
2
namespace App\Requesting;
3

4
use App\Loggers\FileLogger;
5

6
class Requester
7
{
8
    private FileLogger $logger;
9

10
    public function __construct(FileLogger $logger)
393✔
11
    {
12
        $this->logger = $logger;
393✔
13
    }
14

15
    /**
16
     * @param string $url
17
     * @param array  $query
18
     * @param array  $headers
19
     * @param int    $timeout
20
     * @return Response|null
21
     */
22
    public function get($url, array $query = [], array $headers = [], $timeout = 10)
×
23
    {
24
        return $this->curl("GET", $url, $query, [], $headers, $timeout);
×
25
    }
26

27
    /**
28
     * @param string $url
29
     * @param mixed $body
30
     * @param array $headers
31
     * @return Response|null
32
     */
33
    public function post($url, $body = [], array $headers = [])
×
34
    {
35
        return $this->curl("POST", $url, [], $body, $headers);
×
36
    }
37

38
    /**
39
     * @param string $url
40
     * @param mixed $body
41
     * @param array $headers
42
     * @return Response|null
43
     */
44
    public function patch($url, $body = [], array $headers = [])
×
45
    {
46
        return $this->curl("PATCH", $url, [], $body, $headers);
×
47
    }
48

49
    /**
50
     * @param string $url
51
     * @param mixed $body
52
     * @param array $headers
53
     * @return Response|null
54
     */
55
    public function put($url, $body = [], array $headers = [])
×
56
    {
57
        return $this->curl("PUT", $url, [], $body, $headers);
×
58
    }
59

60
    /**
61
     * @param string $url
62
     * @param array $query
63
     * @param array $headers
64
     * @return Response|null
65
     */
66
    public function delete($url, array $query = [], array $headers = [])
×
67
    {
68
        return $this->curl("DELETE", $url, $query, [], $headers);
×
69
    }
70

71
    /**
72
     * @param string $method
73
     * @param string $url
74
     * @param array $query
75
     * @param mixed $body
76
     * @param array $headers
77
     * @param int $timeout
78
     * @return Response|null
79
     */
80
    private function curl(
×
81
        $method,
82
        $url,
83
        array $query = [],
84
        $body = [],
85
        array $headers = [],
86
        $timeout = 10
87
    ) {
88
        if (!empty($query)) {
×
89
            $url .= "?" . http_build_query($query);
×
90
        }
91

92
        $curl = curl_init();
×
93
        curl_setopt_array($curl, [
×
94
            CURLOPT_RETURNTRANSFER => 1,
×
95
            CURLOPT_URL => $url,
×
96
            CURLOPT_CUSTOMREQUEST => $method,
×
97
            CURLOPT_TIMEOUT => $timeout,
×
98
            CURLOPT_USERAGENT => "gammerce/sklep-sms",
×
99
        ]);
×
100

101
        $formattedHeaders = $this->formatHeaders($headers);
×
102
        curl_setopt($curl, CURLOPT_HTTPHEADER, $formattedHeaders);
×
103

104
        if (!empty($body)) {
×
105
            curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
×
106
        }
107

108
        $response = curl_exec($curl);
×
109

110
        if ($response === false) {
×
111
            $this->logger->error("CURL request failed", [
×
112
                "method" => $method,
×
113
                "url" => $url,
×
114
                "error" => curl_error($curl),
×
115
                "error_no" => curl_errno($curl),
×
116
            ]);
×
117
            return null;
×
118
        }
119

120
        $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
×
121
        curl_close($curl);
×
122

123
        return new Response($httpCode, $response);
×
124
    }
125

126
    /**
127
     * @param array $headers
128
     * @return array
129
     */
130
    private function formatHeaders(array $headers)
×
131
    {
132
        $output = [];
×
133

134
        foreach ($headers as $key => $value) {
×
NEW
135
            $output[] = "{$key}: {$value}";
×
136
        }
137

138
        return $output;
×
139
    }
140
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc