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

84 lines
1.6 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);
if ($namespace) {
$this->setNamespace($namespace);
2014-05-18 19:45:50 +02:00
} else {
2014-04-27 14:44:40 +02:00
$fileParts = explode('.', $file);
if (count($fileParts) === 1) {
$this->setNamespace($file);
}
}
}
/**
* Set the File
*
* @param string $file Include File
* @return \FML\Script\ScriptInclude
*/
public function setFile($file) {
$this->file = $file;
return $this;
}
/**
* Set the Namespace
*
* @param string $namespace Include Namespace
* @return \FML\Script\ScriptInclude
*/
public function setNamespace($namespace) {
$this->namespace = $namespace;
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;
}
}