blob: 74b8abf5465b34cb2a8339f5da8f521d8aeb4e9e [file]
<?php
/*******************************************************************************
* Copyright (c) 2023 Eclipse Foundation and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
class SpecificationProcess {
static $instance;
var $versions;
static function init() {
self::$instance = new SpecificationProcess();
}
static function getInstance() {
return self::$instance;
}
private function __construct() {
$data = json_decode(file_get_contents(dirname(__FILE__) . '/../versions.json'), true);
$this->versions = array_map(function($each) {return new SpecificationProcessVersion($each);}, $data);
}
function getVersions() {
return $this->versions;
}
function getVersion($version) {
if ($version) {
foreach($this->versions as $each) {
if ($each->getVersion() == $version) {
return $each;
}
}
}
return $this->getCurrentVersion();
}
function getCurrentVersion() {
foreach($this->versions as $version) {
if ($version->isCurrent()) {
return $version;
}
}
return null;
}
}
class SpecificationProcessVersion {
var $data;
function __construct($data) {
$this->data = $data;
}
function getVersion() {
return $this->data['version'];
}
function getState() {
return $this->data['state'];
}
function getFile() {
$file = $this->data['doc'];
if (!$file) return null;
return dirname(__FILE__) . '/../' . $file;
}
function getDiff() {
$diff = $this->data['diff'];
if (!$diff) return null;
return dirname(__FILE__) . '/../' . $diff;
}
function isCurrent() {
return $this->getState() == 'current';
}
function isDraft() {
return $this->getState() == 'draft';
}
}
SpecificationProcess::init();