TrackManiaControl/libs/FML/ManiaCode/AddBuddy.php

61 lines
1.2 KiB
PHP
Raw Normal View History

2014-01-12 00:51:46 +01:00
<?php
namespace FML\ManiaCode;
/**
2014-06-21 03:18:21 +02:00
* ManiaCode Element adding a buddy
2014-01-12 00:51:46 +01:00
*
2014-06-21 03:18:21 +02:00
* @author steeffeen
2014-04-13 18:21:40 +02:00
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
2014-06-21 03:18:21 +02:00
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
2014-01-12 00:51:46 +01:00
*/
2014-07-03 22:34:47 +02:00
class AddBuddy extends Element {
2014-01-21 20:30:40 +01:00
/*
2014-06-21 03:18:21 +02:00
* Protected properties
2014-01-12 00:51:46 +01:00
*/
protected $tagName = 'add_buddy';
2014-06-21 03:18:21 +02:00
protected $login = null;
2014-01-12 00:51:46 +01:00
2014-01-19 19:30:21 +01:00
/**
2014-06-21 03:18:21 +02:00
* Create a new AddBuddy Element
2014-01-19 19:30:21 +01:00
*
2014-06-21 03:18:21 +02:00
* @param string $login (optional) Buddy login
2014-07-03 22:34:47 +02:00
* @return static
2014-01-19 19:30:21 +01:00
*/
public static function create($login = null) {
2014-06-21 03:18:21 +02:00
return new static($login);
2014-01-19 19:30:21 +01:00
}
2014-01-12 00:51:46 +01:00
/**
* Construct a new AddBuddy Element
*
2014-06-21 03:18:21 +02:00
* @param string $login (optional) Buddy login
2014-01-12 00:51:46 +01:00
*/
public function __construct($login = null) {
2014-08-11 23:15:53 +02:00
if ($login !== null) {
2014-01-12 00:51:46 +01:00
$this->setLogin($login);
}
}
/**
2014-06-21 03:18:21 +02:00
* Set the buddy login
2014-01-12 00:51:46 +01:00
*
2014-06-21 03:18:21 +02:00
* @param string $login Buddy login
2014-07-03 22:34:47 +02:00
* @return static
2014-01-12 00:51:46 +01:00
*/
public function setLogin($login) {
2014-06-21 03:18:21 +02:00
$this->login = (string)$login;
2014-01-12 00:51:46 +01:00
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
2014-07-03 22:34:47 +02:00
$xmlElement = parent::render($domDocument);
2014-01-12 00:51:46 +01:00
$loginElement = $domDocument->createElement('login', $this->login);
$xmlElement->appendChild($loginElement);
return $xmlElement;
}
}