activityReport/src/Formats.php

73 lines
1.4 KiB
PHP
Raw Normal View History

<?php
2021-09-02 22:18:08 +00:00
/**
* @brief activityReport, a plugin for Dotclear 2
2022-11-18 20:24:30 +00:00
*
2021-09-02 22:18:08 +00:00
* @package Dotclear
* @subpackage Plugin
2022-11-18 20:24:30 +00:00
*
2021-09-02 22:18:08 +00:00
* @author Jean-Christian Denis and contributors
2022-11-18 20:24:30 +00:00
*
2021-09-02 22:18:08 +00:00
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\activityReport;
/**
* Email report formats stack.
*/
class Formats
{
/** @var array<string, Format> $stack The formats stack */
private array $stack = [];
/**
* Chek if a format exists.
*
* @param string $id The format ID
*
* @return bool True if it exists
*/
public function has(string $id): bool
{
return isset($this->stack[$id]);
}
/**
* Add a format.
*
* @param Format $format The format object
*
* @return Formats The formats instance
*/
public function add(Format $format): Formats
{
$this->stack[$format->id] = $format;
return $this;
}
/**
* Get a format.
*
* @param string $id The format ID
*
* @return Format The format descriptor
*/
public function get(string $id): Format
{
return $this->stack[$id] ?? new Format('plain', []);
}
/**
* Get all formats.
*
* @return array<string, Format> The formats stack
*/
public function dump(): array
{
return $this->stack;
}
}