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

sirn-se / websocket-php / 8346487915

19 Mar 2024 04:15PM UTC coverage: 22.584% (-77.4%) from 100.0%
8346487915

push

github

sirn-se
Temp test verification

2 of 2 new or added lines in 1 file covered. (100.0%)

742 existing lines in 32 files now uncovered.

222 of 983 relevant lines covered (22.58%)

0.23 hits per line

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

0.0
/src/Message/Close.php
1
<?php
2

3
/**
4
 * Copyright (C) 2014-2024 Textalk and contributors.
5
 * This file is part of Websocket PHP and is free software under the ISC License.
6
 */
7

8
namespace WebSocket\Message;
9

10
/**
11
 * WebSocket\Message\Close class.
12
 * A Close WebSocket message.
13
 */
14
class Close extends Message
15
{
16
    protected $opcode = 'close';
17
    protected $status = null;
18

19
    public function __construct(int|null $status = null, string $content = '')
20
    {
UNCOV
21
        $this->status = $status;
×
UNCOV
22
        parent::__construct($content);
×
23
    }
24

25
    public function getCloseStatus(): int|null
26
    {
UNCOV
27
        return $this->status;
×
28
    }
29

30
    public function setCloseStatus(int|null $status): void
31
    {
UNCOV
32
        $this->status = $status;
×
33
    }
34

35
    public function getPayload(): string
36
    {
UNCOV
37
        $status_binstr = sprintf('%016b', $this->status);
×
UNCOV
38
        $status_str = '';
×
UNCOV
39
        foreach (str_split($status_binstr, 8) as $binstr) {
×
UNCOV
40
            $status_str .= chr(bindec($binstr));
×
41
        }
UNCOV
42
        return $status_str . $this->content;
×
43
    }
44

45
    public function setPayload(string $payload = ''): void
46
    {
UNCOV
47
        $this->status = 0;
×
UNCOV
48
        $this->content = '';
×
UNCOV
49
        if (strlen($payload) > 0) {
×
UNCOV
50
            $this->status = current(unpack('n', $payload));
×
51
        }
UNCOV
52
        if (strlen($payload) > 2) {
×
UNCOV
53
            $this->content = substr($payload, 2);
×
54
        }
55
    }
56
}
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

© 2025 Coveralls, Inc