mini-fair-repo/inc/api/class-releasedocument.php
Joost de Valk d527f95815
Do plugin rename (#78)
Signed-off-by: Joost de Valk <joost@altha.nl>
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
2025-11-24 12:58:34 -08:00

80 lines
1.3 KiB
PHP

<?php
/**
* Release Document.
*
* @package FAIR\Beacon
*/
namespace FAIR\Beacon\API;
use JsonSerializable;
/**
* ReleaseDocument class.
*/
class ReleaseDocument implements JsonSerializable {
/**
* Version.
*
* @var string
*/
public string $version;
/**
* Requirements.
*
* @var array
*/
public array $requires;
/**
* Suggested additional packages.
*
* @var array
*/
public array $suggests;
/**
* Provided capabilities.
*
* @var array
*/
public array $provides;
/**
* Artifacts.
*
* @var array
*/
public array $artifacts;
/**
* Add an artifact to the release document.
*
* @param string $type The type of artifact.
* @param array $data The artifact's data.
* @return void
*/
protected function add_artifact( string $type, array $data ) : void {
if ( ! isset( $this->artifacts[ $type ] ) ) {
$this->artifacts[ $type ] = [];
}
$this->artifacts[ $type ][] = $data;
}
/**
* Return data that should be serialized to JSON.
*
* @return array
*/
public function jsonSerialize() : array {
return [
'@context' => 'https://fair.pm/ns/release/v1',
'version' => $this->version,
'requires' => $this->requires,
'suggests' => $this->suggests,
'provides' => $this->provides,
'artifacts' => $this->artifacts,
];
}
}