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

daycry / queues / 7059913013

29 Nov 2023 11:03AM UTC coverage: 81.707% (-1.0%) from 82.683%
7059913013

push

github

web-flow
Update README.md

335 of 410 relevant lines covered (81.71%)

10.2 hits per line

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

92.59
/src/Libraries/ServiceBusHeaders.php
1
<?php
2

3
namespace Daycry\Queues\Libraries;
4

5
use CodeIgniter\I18n\Time;
6
use DateTime;
7
use DateTimeZone;
8

9
class ServiceBusHeaders
10
{
11
    private array $brokerProperties = [];
12
    private string $authorization = "";
13

14
    public function generateMessageId(?string $messageId = null): self
15
    {
16
        helper('text');
11✔
17

18
        $messageId = ($messageId) ? $messageId : random_string('alnum', 32);
11✔
19
        $messageId = (getenv('MESSAGEID')) ? getenv('MESSAGEID') : $messageId;
11✔
20
        $this->brokerProperties['MessageId'] = $messageId;
11✔
21

22
        return $this;
11✔
23
    }
24

25
    public function getMessageId(): string
26
    {
27
        return $this->brokerProperties['MessageId'];
6✔
28
    }
29

30
    public function setLabel(string $label): self
31
    {
32
        $this->brokerProperties['Label'] = $label;
1✔
33

34
        return $this;
1✔
35
    }
36

37
    public function schedule(DateTime $datetime): self
38
    {
39
        $this->brokerProperties['ScheduledEnqueueTimeUtc'] = $datetime->setTimezone(new DateTimeZone('UTC'))->getTimestamp();
×
40

41
        return $this;
×
42
    }
43

44
    public function generateSasToken($uri, $sasKeyName, $sasKeyValue): self
45
    {
46
        $expires = (getenv('MOCK_TIME')) ? Time::createFromTimestamp((int)getenv('MOCK_TIME')) : Time::now();
11✔
47

48
        $targetUri = strtolower(rawurlencode(strtolower($uri)));
11✔
49
        $week = 60*60*24*7;
11✔
50
        $expires = $expires->getTimestamp() + $week;
11✔
51
        $toSign = $targetUri . "\n" . $expires;
11✔
52
        $signature = rawurlencode(base64_encode(hash_hmac(
11✔
53
            'sha256',
11✔
54
            $toSign,
11✔
55
            $sasKeyValue,
11✔
56
            true
11✔
57
        )));
11✔
58

59

60
        $this->authorization = "SharedAccessSignature sr=" . $targetUri . "&sig=" . $signature . "&se=" . $expires .         "&skn=" . $sasKeyName;
11✔
61

62
        return $this;
11✔
63
    }
64

65
    public function getHeaders(): array
66
    {
67
        return [
11✔
68
            'Authorization' => $this->authorization,
11✔
69
            'BrokerProperties' => json_encode($this->brokerProperties)
11✔
70
        ];
11✔
71
    }
72
}
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