84 lines
1.7 KiB
PHP
84 lines
1.7 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace NoccyLabs\Hotfix\Hotfix;
|
||
|
|
||
|
use Symfony\Component\Yaml\Yaml;
|
||
|
use NoccyLabs\Hotfix\Exception\HotfixException;
|
||
|
|
||
|
class Header
|
||
|
{
|
||
|
/**
|
||
|
* @var string The name of the hotfix
|
||
|
*/
|
||
|
protected $name;
|
||
|
|
||
|
/**
|
||
|
* @var string Information about this hotfix
|
||
|
*/
|
||
|
protected $info;
|
||
|
|
||
|
/**
|
||
|
* @var string The author of the hotfix
|
||
|
*/
|
||
|
protected $author;
|
||
|
|
||
|
/**
|
||
|
* @var string The language this hotfix is written in, should match a runner.
|
||
|
*/
|
||
|
protected $language;
|
||
|
|
||
|
/**
|
||
|
* @var array A list of expressions to verify that the system is compatible
|
||
|
* with this fix
|
||
|
*/
|
||
|
protected $requirements;
|
||
|
|
||
|
public function __construct($header)
|
||
|
{
|
||
|
$header = Yaml::parse($header);
|
||
|
|
||
|
if (!(
|
||
|
array_key_exists('hotfix', $header) &&
|
||
|
array_key_exists('author', $header) &&
|
||
|
array_key_exists('info', $header) &&
|
||
|
array_key_exists('lang', $header)
|
||
|
)) {
|
||
|
throw new HotfixException("Invalid hotfix, header is missing hotfix, author, info or lang fields.");
|
||
|
}
|
||
|
|
||
|
$this->name = $header['hotfix'];
|
||
|
$this->author = $header['author'];
|
||
|
$this->info = $header['info'];
|
||
|
$this->language = $header['lang'];
|
||
|
|
||
|
if (array_key_exists('for', $header)) {
|
||
|
$this->requirements = $header['for'];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function getName()
|
||
|
{
|
||
|
return $this->name;
|
||
|
}
|
||
|
|
||
|
public function getAuthor()
|
||
|
{
|
||
|
return $this->author;
|
||
|
}
|
||
|
|
||
|
public function getInfo()
|
||
|
{
|
||
|
return $this->info;
|
||
|
}
|
||
|
|
||
|
public function getLanguage()
|
||
|
{
|
||
|
return $this->language;
|
||
|
}
|
||
|
|
||
|
public function getRequirements()
|
||
|
{
|
||
|
return $this->requirements;
|
||
|
}
|
||
|
}
|