TrackManiaControl/application/core/Libs/FML/ManiaCode/PlayMap.php

81 lines
1.8 KiB
PHP
Raw Normal View History

2014-01-12 00:51:46 +01:00
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element playing a Map
*
2014-05-20 15:44:45 +02:00
* @author steeffeen <mail@steeffeen.com>
2014-04-13 18:21:40 +02:00
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
2014-05-18 19:45:50 +02:00
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
2014-01-12 00:51:46 +01:00
*/
class PlayMap implements Element {
2014-01-21 20:30:40 +01:00
/*
2014-01-12 00:51:46 +01:00
* Protected Properties
*/
protected $tagName = 'play_map';
protected $name = '';
protected $url = '';
2014-01-19 19:30:21 +01:00
/**
* Create a new PlayMap Element
*
* @param string $name (optional) Map Name
2014-05-18 19:45:50 +02:00
* @param string $url (optional) Map Url
2014-01-19 19:30:21 +01:00
* @return \FML\ManiaCode\PlayMap
*/
public static function create($name = null, $url = null) {
$playMap = new PlayMap($name, $url);
return $playMap;
}
2014-01-12 00:51:46 +01:00
/**
* Construct a new PlayMap Element
*
* @param string $name (optional) Map Name
2014-05-18 19:45:50 +02:00
* @param string $url (optional) Map Url
2014-01-12 00:51:46 +01:00
*/
public function __construct($name = null, $url = null) {
if ($name !== null) {
$this->setName($name);
}
if ($url !== null) {
$this->setUrl($url);
}
}
/**
* Set the Name of the Map
*
* @param string $name Map Name
* @return \FML\ManiaCode\PlayMap
*/
public function setName($name) {
2014-05-18 19:45:50 +02:00
$this->name = (string)$name;
2014-01-12 00:51:46 +01:00
return $this;
}
/**
* Set the Url of the Map
*
* @param string $url Map Url
* @return \FML\ManiaCode\PlayMap
*/
public function setUrl($url) {
2014-05-18 19:45:50 +02:00
$this->url = (string)$url;
2014-01-12 00:51:46 +01:00
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
2014-05-18 19:45:50 +02:00
$xmlElement = $domDocument->createElement($this->tagName);
2014-01-12 00:51:46 +01:00
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
}
}