| 1 |
<?php |
| 2 |
/** |
| 3 |
* Output buffer for the MCP CLI bridge — collects the lines a bridged |
| 4 |
* xSpeed CLI command emits (via the \WP_CLI shim) during a run, so the |
| 5 |
* bridge can return them as structured MCP output. See Cli_Shim. |
| 6 |
* |
| 7 |
* @package XSpeed |
| 8 |
*/ |
| 9 |
|
| 10 |
declare(strict_types=1); |
| 11 |
|
| 12 |
namespace XSpeed\Modules\Mcp; |
| 13 |
|
| 14 |
defined( 'ABSPATH' ) || exit; |
| 15 |
|
| 16 |
final class Cli_Output_Buffer { |
| 17 |
|
| 18 |
/** @var string[] */ |
| 19 |
private $lines = array(); |
| 20 |
|
| 21 |
public function push( string $line ): void { |
| 22 |
$this->lines[] = $line; |
| 23 |
} |
| 24 |
|
| 25 |
/** @return string[] */ |
| 26 |
public function lines(): array { |
| 27 |
return $this->lines; |
| 28 |
} |
| 29 |
|
| 30 |
public function text(): string { |
| 31 |
return implode( "\n", $this->lines ); |
| 32 |
} |
| 33 |
} |
| 34 |
|