Files
DomFramework/src/GraphSeries.php

74 lines
1.8 KiB
PHP

<?php
/** DomFramework
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD
*/
namespace Domframework;
/** The series objects */
class GraphSeries
{
/** The series stored */
private $series = array();
/** Return the serie object choosed. If doesn't exists, it is created before
* be returned
* @param string $name The name of the serie to create
*/
public function serie($name)
{
if (is_integer($name)) {
$name = dgettext("domframework", "Serie") . " $name";
}
if (! is_string($name)) {
throw new \Exception(
dgettext(
"domframework",
"Can't get a serie if the name is not a string"
),
406
);
}
if (! array_key_exists($name, $this->series)) {
$this->series[$name] = new GraphSerie($name);
}
return $this->series[$name];
}
/** Get the list of the defined series
*/
public function getList()
{
$series = [];
foreach ($this->series as $name => $serie) {
if ($serie->hide() === true) {
continue;
}
$series[] = $name;
}
return $series;
}
/** Remove an existing serie
* @param string $name The name of the serie to remove
*/
public function remove($name)
{
if (! is_string($name)) {
throw new \Exception(
dgettext(
"domframework",
"Can't remove a serie if the name is not a string"
),
406
);
}
if (array_key_exists($name, $this->series)) {
unset($this->series[$name]);
}
}
}