TrackManiaControl/libs/FML/Script/ScriptInclude.php

107 lines
1.9 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
2017-03-25 18:40:15 +01:00
* @copyright FancyManiaLinks Copyright © 2017 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
*/
2017-03-25 18:40:15 +01:00
class ScriptInclude
{
2014-05-18 19:45:50 +02:00
2017-03-25 18:40:15 +01:00
/*
* Constants
*/
const MATHLIB = 'MathLib';
const TEXTLIB = 'TextLib';
2014-04-27 14:44:40 +02:00
2017-03-25 18:40:15 +01:00
/**
* @var string $file File name
*/
protected $file = null;
2014-04-27 14:44:40 +02:00
2017-03-25 18:40:15 +01:00
/**
* @var string $namespace Namespace
*/
protected $namespace = null;
2014-04-27 14:44:40 +02:00
2017-03-25 18:40:15 +01:00
/**
* Construct a new Script Include
*
* @api
* @param string $file (optional) File name
* @param string $namespace (optional) Namespace
*/
public function __construct($file = null, $namespace = null)
{
if ($file) {
$this->setFile($file);
}
if ($namespace) {
$this->setNamespace($namespace);
}
}
2014-04-27 14:44:40 +02:00
2017-03-25 18:40:15 +01:00
/**
* Get the file
*
* @api
* @return string
*/
public function getFile()
{
return $this->file;
}
/**
* Set the file
*
* @api
* @param string $file File name
* @return static
*/
public function setFile($file)
{
$this->file = (string)$file;
return $this;
}
/**
* Get the namespace
*
* @api
* @return string
*/
public function getNamespace()
{
return $this->namespace;
}
/**
* Set the namespace
*
* @api
* @param string $namespace Namespace
* @return static
*/
public function setNamespace($namespace)
{
$this->namespace = (string)$namespace;
return $this;
}
/**
* Build the Script Include text
*
* @return string
*/
public function __toString()
{
return Builder::getInclude($this->file, $this->namespace);
}
2014-04-27 14:44:40 +02:00
}