PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 2.8.16
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v2.8.16
3.13.4 3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 All 262 releases
wpfunnels / vendor / symfony / http-client / Chunk / ServerSentEvent.php

ServerSentEvent.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 2.8.16, at vendor/symfony/http-client/Chunk/ServerSentEvent.php

80 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\HttpClient\Chunk;
13
14 use Symfony\Contracts\HttpClient\ChunkInterface;
15
16 /**
17 * @author Antoine Bluchet <[email protected]>
18 * @author Nicolas Grekas <[email protected]>
19 */
20 final class ServerSentEvent extends DataChunk implements ChunkInterface
21 {
22 private $data = '';
23 private $id = '';
24 private $type = 'message';
25 private $retry = 0;
26
27 public function __construct(string $content)
28 {
29 parent::__construct(-1, $content);
30
31 // remove BOM
32 if (0 === strpos($content, "\xEF\xBB\xBF")) {
33 $content = substr($content, 3);
34 }
35
36 foreach (preg_split("/(?:\r\n|[\r\n])/", $content) as $line) {
37 if (0 === $i = strpos($line, ':')) {
38 continue;
39 }
40
41 $i = false === $i ? \strlen($line) : $i;
42 $field = substr($line, 0, $i);
43 $i += 1 + (' ' === ($line[1 + $i] ?? ''));
44
45 switch ($field) {
46 case 'id': $this->id = substr($line, $i); break;
47 case 'event': $this->type = substr($line, $i); break;
48 case 'data': $this->data .= ('' === $this->data ? '' : "\n").substr($line, $i); break;
49 case 'retry':
50 $retry = substr($line, $i);
51
52 if ('' !== $retry && \strlen($retry) === strspn($retry, '0123456789')) {
53 $this->retry = $retry / 1000.0;
54 }
55 break;
56 }
57 }
58 }
59
60 public function getId(): string
61 {
62 return $this->id;
63 }
64
65 public function getType(): string
66 {
67 return $this->type;
68 }
69
70 public function getData(): string
71 {
72 return $this->data;
73 }
74
75 public function getRetry(): float
76 {
77 return $this->retry;
78 }
79 }
80