• 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/Middleware/Callback.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\Middleware;
9

10
use Closure;
11
use Psr\Log\{
12
    LoggerAwareInterface,
13
    LoggerAwareTrait
14
};
15
use Stringable;
16
use WebSocket\Connection;
17
use WebSocket\Http\Message as HttpMessage;
18
use WebSocket\Message\Message;
19
use WebSocket\Trait\StringableTrait;
20

21
/**
22
 * WebSocket\Middleware\Callback class.
23
 * Generic middleware using callbacks.
24
 */
25
class Callback implements
26
    LoggerAwareInterface,
27
    ProcessHttpIncomingInterface,
28
    ProcessHttpOutgoingInterface,
29
    ProcessIncomingInterface,
30
    ProcessOutgoingInterface,
31
    ProcessTickInterface,
32
    Stringable
33
{
34
    use LoggerAwareTrait;
35
    use StringableTrait;
36

37
    private $incoming;
38
    private $outgoing;
39
    private $httpIncoming;
40
    private $httpOutgoing;
41
    private $tick;
42

43
    public function __construct(
44
        Closure|null $incoming = null,
45
        Closure|null $outgoing = null,
46
        Closure|null $httpIncoming = null,
47
        Closure|null $httpOutgoing = null,
48
        Closure|null $tick = null,
49
    ) {
UNCOV
50
        $this->incoming = $incoming;
×
UNCOV
51
        $this->outgoing = $outgoing;
×
UNCOV
52
        $this->httpIncoming = $httpIncoming;
×
UNCOV
53
        $this->httpOutgoing = $httpOutgoing;
×
UNCOV
54
        $this->tick = $tick;
×
55
    }
56

57
    public function processIncoming(ProcessStack $stack, Connection $connection): Message
58
    {
UNCOV
59
        if (is_callable($this->incoming)) {
×
UNCOV
60
            return call_user_func($this->incoming, $stack, $connection);
×
61
        }
UNCOV
62
        return $stack->handleIncoming();
×
63
    }
64

65
    public function processOutgoing(ProcessStack $stack, Connection $connection, Message $message): Message
66
    {
UNCOV
67
        if (is_callable($this->outgoing)) {
×
UNCOV
68
            return call_user_func($this->outgoing, $stack, $connection, $message);
×
69
        }
UNCOV
70
        return $stack->handleOutgoing($message);
×
71
    }
72

73
    public function processHttpIncoming(ProcessHttpStack $stack, Connection $connection): HttpMessage
74
    {
UNCOV
75
        if (is_callable($this->httpIncoming)) {
×
UNCOV
76
            return call_user_func($this->httpIncoming, $stack, $connection);
×
77
        }
UNCOV
78
        return $stack->handleHttpIncoming();
×
79
    }
80

81
    public function processHttpOutgoing(
82
        ProcessHttpStack $stack,
83
        Connection $connection,
84
        HttpMessage $message
85
    ): HttpMessage {
UNCOV
86
        if (is_callable($this->httpOutgoing)) {
×
UNCOV
87
            return call_user_func($this->httpOutgoing, $stack, $connection, $message);
×
88
        }
UNCOV
89
        return $stack->handleHttpOutgoing($message);
×
90
    }
91

92
    public function processTick(ProcessTickStack $stack, Connection $connection): void
93
    {
UNCOV
94
        if (is_callable($this->tick)) {
×
UNCOV
95
            call_user_func($this->tick, $stack, $connection);
×
96
        }
UNCOV
97
        $stack->handleTick();
×
98
    }
99
}
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