TrackManiaControl/application/core/Libs/FML/Script/ScriptInclude.php

77 lines
1.4 KiB
PHP
Raw Normal View History

2014-04-27 14:44:40 +02:00
<?php
namespace FML\Script;
/**
* Class representing an Include of the ManiaLink Script
*
2014-05-18 19:45:50 +02:00
* @author steeffeen
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 ScriptInclude {
/*
* Constants
*/
const MATHLIB = 'MathLib';
const TEXTLIB = 'TextLib';
2014-05-18 19:45:50 +02:00
2014-04-27 14:44:40 +02:00
/*
* Protected Properties
*/
protected $file = null;
protected $namespace = null;
/**
* Construct a new Script Include
*
2014-05-18 19:45:50 +02:00
* @param string $file (optional) Include File
2014-04-27 14:44:40 +02:00
* @param string $namespace (optional) Include Namespace
*/
public function __construct($file = null, $namespace = null) {
$this->setFile($file);
2014-05-20 15:44:45 +02:00
$this->setNamespace($namespace);
2014-04-27 14:44:40 +02:00
}
/**
* Set the File
*
* @param string $file Include File
* @return \FML\Script\ScriptInclude
*/
public function setFile($file) {
2014-05-20 15:44:45 +02:00
$this->file = (string)$file;
2014-04-27 14:44:40 +02:00
return $this;
}
/**
* Set the Namespace
*
* @param string $namespace Include Namespace
* @return \FML\Script\ScriptInclude
*/
public function setNamespace($namespace) {
2014-05-20 15:44:45 +02:00
$this->namespace = (string)$namespace;
2014-04-27 14:44:40 +02:00
return $this;
}
/**
* Get the Namespace
*
* @return string
*/
public function getNamespace() {
return $this->namespace;
}
/**
* Build the Script Include Text
*
* @return string
*/
public function __toString() {
$scriptText = Builder::getInclude($this->file, $this->namespace);
return $scriptText;
}
}