mirror of
https://gh.wpcy.net/https://github.com/fairpm/mini-fair-repo.git
synced 2026-06-19 02:23:34 +08:00
Signed-off-by: Joost de Valk <joost@altha.nl> Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
80 lines
1.3 KiB
PHP
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,
|
|
];
|
|
}
|
|
}
|