TrackManiaControl/libs/FML/Script/ScriptConstant.php

61 lines
1.1 KiB
PHP
Raw Normal View History

2014-04-27 14:44:40 +02:00
<?php
namespace FML\Script;
/**
* Class representing a Constant of the ManiaLink Script
*
2014-05-20 15:44:45 +02:00
* @author steeffeen <mail@steeffeen.com>
2014-04-27 14:44: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-04-27 14:44:40 +02:00
*/
class ScriptConstant {
/*
2014-06-21 03:18:21 +02:00
* Protected properties
2014-04-27 14:44:40 +02:00
*/
protected $name = null;
protected $value = null;
/**
* Construct a new Script Constant
*
2014-06-21 03:18:21 +02:00
* @param string $name (optional) Constant name
* @param string $value (optional) Constant value
2014-04-27 14:44:40 +02:00
*/
public function __construct($name = null, $value = null) {
$this->setName($name);
$this->setValue($value);
}
/**
2014-06-21 03:18:21 +02:00
* Set the name
2014-04-27 14:44:40 +02:00
*
2014-06-21 03:18:21 +02:00
* @param string $name Constant name
2014-07-03 22:34:47 +02:00
* @return static
2014-04-27 14:44:40 +02:00
*/
public function setName($name) {
2014-06-21 03:18:21 +02:00
$this->name = (string)$name;
2014-04-27 14:44:40 +02:00
return $this;
}
/**
2014-06-21 03:18:21 +02:00
* Set the value
2014-04-27 14:44:40 +02:00
*
2014-06-21 03:18:21 +02:00
* @param string $value Constant value
2014-07-03 22:34:47 +02:00
* @return static
2014-04-27 14:44:40 +02:00
*/
public function setValue($value) {
$this->value = $value;
return $this;
}
/**
2014-06-21 03:18:21 +02:00
* Build the Script Constant text
2014-04-27 14:44:40 +02:00
*
* @return string
*/
public function __toString() {
2014-06-21 03:18:21 +02:00
return Builder::getConstant($this->name, $this->value);
2014-04-27 14:44:40 +02:00
}
}