Fixed: basePath self→static binding, namespace detection, event wiring,
SQLite cache, file cache driver. All Mod Boot classes converted to
$listens pattern for lifecycle event discovery.
Working endpoints:
- /v1/explorer/info — live chain height, difficulty, aliases
- /v1/explorer/stats — formatted chain statistics
- /v1/names/directory — alias directory grouped by type
- /v1/names/available/{name} — name availability check
- /v1/names/lookup/{name} — name details
Co-Authored-By: Charon <charon@lethean.io>
74 lines
1.4 KiB
PHP
74 lines
1.4 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Core PHP Framework
|
|
*
|
|
* Licensed under the European Union Public Licence (EUPL) v1.2.
|
|
* See LICENSE file for details.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Core\Helpers;
|
|
|
|
/**
|
|
* Represents the result of a remote command execution.
|
|
*/
|
|
class CommandResult
|
|
{
|
|
public function __construct(
|
|
public readonly string $output,
|
|
public readonly int $exitCode = 0,
|
|
public readonly ?string $error = null
|
|
) {}
|
|
|
|
/**
|
|
* Check if the command was successful.
|
|
*/
|
|
public function isSuccessful(): bool
|
|
{
|
|
return $this->exitCode === 0;
|
|
}
|
|
|
|
/**
|
|
* Check if the command failed.
|
|
*/
|
|
public function isFailed(): bool
|
|
{
|
|
return ! $this->isSuccessful();
|
|
}
|
|
|
|
/**
|
|
* Get the output lines as an array.
|
|
*/
|
|
public function getLines(): array
|
|
{
|
|
return array_filter(explode("\n", $this->output));
|
|
}
|
|
|
|
/**
|
|
* Get the first line of output.
|
|
*/
|
|
public function getFirstLine(): ?string
|
|
{
|
|
$lines = $this->getLines();
|
|
|
|
return $lines[0] ?? null;
|
|
}
|
|
|
|
/**
|
|
* Check if output contains a string.
|
|
*/
|
|
public function contains(string $needle): bool
|
|
{
|
|
return str_contains($this->output, $needle);
|
|
}
|
|
|
|
/**
|
|
* Get the output as a string.
|
|
*/
|
|
public function __toString(): string
|
|
{
|
|
return $this->output;
|
|
}
|
|
}
|