TrackManiaControl/libs/FML/Elements/Music.php

84 lines
1.5 KiB
PHP
Raw Permalink Normal View History

<?php
namespace FML\Elements;
2014-01-12 00:51:46 +01:00
use FML\Types\Renderable;
/**
2014-01-12 00:51:46 +01:00
* Music Element
*
2014-05-20 15:44:45 +02:00
* @author steeffeen <mail@steeffeen.com>
2017-03-25 18:40:15 +01:00
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
2014-05-18 19:45:50 +02:00
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
2017-03-25 18:40:15 +01:00
class Music implements Renderable
{
/**
* @var string $data Media url
*/
protected $data = null;
/**
* Create a new Music
*
* @api
* @param string $data (optional) Media url
* @return static
*/
public static function create($data = null)
{
return new static($data);
}
/**
* Construct a new Music
*
* @api
* @param string $data (optional) Media url
*/
public function __construct($data = null)
{
if ($data) {
$this->setData($data);
}
}
/**
* Get the media url
*
* @api
* @return string
*/
public function getData()
{
return $this->data;
}
/**
* Set the media url
*
* @api
* @param string $data Media url
* @return static
*/
public function setData($data)
{
$this->data = (string)$data;
return $this;
}
/**
* @see Renderable::render()
*/
public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("music");
if ($this->data) {
$domElement->setAttribute("data", $this->data);
}
return $domElement;
}
}