TrackManiaControl/application/libs/FML/Script/ScriptInclude.php

76 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
/*
2014-06-21 03:18:21 +02:00
* Protected properties
2014-04-27 14:44:40 +02:00
*/
protected $file = null;
protected $namespace = null;
/**
* Construct a new Script Include
*
2014-06-21 03:18:21 +02:00
* @param string $file (optional) Include file
* @param string $namespace (optional) Include namespace
2014-04-27 14:44:40 +02:00
*/
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
}
/**
2014-06-21 03:18:21 +02:00
* Set the file
2014-04-27 14:44:40 +02:00
*
2014-06-21 03:18:21 +02:00
* @param string $file Include file
2014-07-03 22:34:47 +02:00
* @return static
2014-04-27 14:44:40 +02:00
*/
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;
}
/**
2014-06-21 03:18:21 +02:00
* Set the namespace
2014-04-27 14:44:40 +02:00
*
2014-06-21 03:18:21 +02:00
* @param string $namespace Include namespace
2014-07-03 22:34:47 +02:00
* @return static
2014-04-27 14:44:40 +02:00
*/
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;
}
/**
2014-06-21 03:18:21 +02:00
* Get the namespace
2014-04-27 14:44:40 +02:00
*
* @return string
*/
public function getNamespace() {
return $this->namespace;
}
/**
2014-06-21 03:18:21 +02:00
* Build the Script Include text
2014-04-27 14:44:40 +02:00
*
* @return string
*/
public function __toString() {
2014-06-21 03:18:21 +02:00
return Builder::getInclude($this->file, $this->namespace);
2014-04-27 14:44:40 +02:00
}
}