added UsageInformationTrait / INterface + updated mindediversion
This commit is contained in:
parent
de3bae9029
commit
46daaee61a
@ -3,8 +3,9 @@
|
||||
namespace ManiaControl\Callbacks\Structures;
|
||||
|
||||
|
||||
use ManiaControl\General\UsageInformationAble;
|
||||
use ManiaControl\General\UsageInformationTrait;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* Base Structure of all Callback Structures
|
||||
@ -13,7 +14,9 @@ use ReflectionClass;
|
||||
* @copyright 2014-2017 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
abstract class BaseStructure {
|
||||
abstract class BaseStructure implements UsageInformationAble {
|
||||
use UsageInformationTrait;
|
||||
|
||||
/** @var ManiaControl $maniaControl */
|
||||
protected $maniaControl;
|
||||
private $plainJsonObject;
|
||||
@ -29,36 +32,4 @@ abstract class BaseStructure {
|
||||
public function getPlainJsonObject() {
|
||||
return $this->plainJsonObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Information about the Class, and a List of the Public Method
|
||||
*/
|
||||
public function getUsage() {
|
||||
$reflection = new ReflectionClass(get_class($this));
|
||||
echo $reflection->getDocComment();
|
||||
|
||||
echo "\nStructure Name of Class = " . get_class($this);
|
||||
|
||||
echo "\nMethods:\n";
|
||||
|
||||
$metody = $reflection->getMethods();
|
||||
$methods = array_reverse($metody);
|
||||
foreach ($methods as $key => $value) {
|
||||
/** @var \ReflectionMethod $value */
|
||||
//Don't print the Constructor
|
||||
if ($value->isPublic() && $value->getName() != "__construct" && $value->getName() != "getUsage") {
|
||||
echo "\n\n";
|
||||
$txt = preg_replace('/\t/', '', $value->getDocComment());
|
||||
|
||||
echo $txt;
|
||||
echo "\n \$result = " . $value->getName() . "();";
|
||||
$parameters = $value->getParameters();
|
||||
|
||||
foreach ($parameters as $parameter) {
|
||||
echo "\n" . $parameter;
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -14,9 +14,9 @@ use ManiaControl\ManiaControl;
|
||||
*/
|
||||
class CallbacksListStructure extends BaseStructure {
|
||||
/** @var string $responseId */
|
||||
public $responseId;
|
||||
private $responseId;
|
||||
/** @var array $callbacks */
|
||||
public $callbacks;
|
||||
private $callbacks;
|
||||
|
||||
/**
|
||||
* Construct a new Callbacks List Structure
|
||||
@ -29,11 +29,11 @@ class CallbacksListStructure extends BaseStructure {
|
||||
|
||||
$this->responseId = $this->getPlainJsonObject()->responseid;
|
||||
$this->callbacks = $this->getPlainJsonObject()->callbacks;
|
||||
|
||||
$this->getUsage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Response Id //TODO Trait for all Response Ids
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResponseId() {
|
||||
@ -41,7 +41,9 @@ class CallbacksListStructure extends BaseStructure {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* Get Array of the Callbacks
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getCallbacks() {
|
||||
return $this->callbacks;
|
||||
|
@ -1,14 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Lukas
|
||||
* Date: 24. Mär. 2017
|
||||
* Time: 21:59
|
||||
*/
|
||||
|
||||
namespace ManiaControl\General;
|
||||
|
||||
|
||||
/**
|
||||
* Class DumpTrait Trait for Implementing the Methods for the dumpable Interface
|
||||
*
|
||||
* @package ManiaControl\General
|
||||
*/
|
||||
trait DumpTrait {
|
||||
/**
|
||||
* Var_Dump Public Properties of the Object
|
||||
|
@ -1,14 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Lukas
|
||||
* Date: 24. Mär. 2017
|
||||
* Time: 21:58
|
||||
*/
|
||||
|
||||
namespace ManiaControl\General;
|
||||
|
||||
|
||||
/**
|
||||
* Object implementing this Interface has a dump() Method
|
||||
*
|
||||
* @package ManiaControl\General
|
||||
*/
|
||||
interface Dumpable {
|
||||
public function dump();
|
||||
}
|
12
core/General/UsageInformationAble.php
Normal file
12
core/General/UsageInformationAble.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\General;
|
||||
|
||||
/**
|
||||
* Object implementing this Interface has a dump() Method
|
||||
*
|
||||
* @package ManiaControl\General
|
||||
*/
|
||||
interface UsageInformationAble {
|
||||
public function getUsage();
|
||||
}
|
41
core/General/UsageInformationTrait.php
Normal file
41
core/General/UsageInformationTrait.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\General;
|
||||
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* Class DumpTrait Trait for Implementing the Methods for the UsageInformationAble Interface
|
||||
*
|
||||
* @package ManiaControl\General
|
||||
*/
|
||||
trait UsageInformationTrait {
|
||||
/**
|
||||
* Gets Information about the Class, and a List of the Public Method
|
||||
*/
|
||||
public function getUsage() {
|
||||
$reflection = new ReflectionClass(get_class($this));
|
||||
echo $reflection->getDocComment();
|
||||
|
||||
echo "\nStructure Name of Class = " . get_class($this);
|
||||
echo "\n\nMethods:";
|
||||
|
||||
$methods = array_reverse($reflection->getMethods());
|
||||
foreach ($methods as $key => $value) {
|
||||
/** @var \ReflectionMethod $value */
|
||||
//Don't print the Constructor
|
||||
if ($value->isPublic() && $value->getName() != "__construct" && $value->getName() != "getUsage") {
|
||||
echo "\n";
|
||||
echo preg_replace('/\t/', '', $value->getDocComment());
|
||||
echo "\n \$result = " . $value->getName() . "(); \n";
|
||||
$parameters = $value->getParameters();
|
||||
|
||||
foreach ($parameters as $parameter) {
|
||||
echo $parameter . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "\n";
|
||||
//TODO add public Constands and Properties
|
||||
}
|
||||
}
|
@ -21,6 +21,8 @@ use ManiaControl\Configurator\Configurator;
|
||||
use ManiaControl\Database\Database;
|
||||
use ManiaControl\Files\AsynchronousFileReader;
|
||||
use ManiaControl\Files\FileUtil;
|
||||
use ManiaControl\General\UsageInformationAble;
|
||||
use ManiaControl\General\UsageInformationTrait;
|
||||
use ManiaControl\Manialinks\ManialinkManager;
|
||||
use ManiaControl\Maps\MapManager;
|
||||
use ManiaControl\Players\Player;
|
||||
@ -44,13 +46,15 @@ use Maniaplanet\DedicatedServer\Xmlrpc\TransportException;
|
||||
* @copyright 2014-2017 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class ManiaControl implements CallbackListener, CommandListener, TimerListener, CommunicationListener {
|
||||
class ManiaControl implements CallbackListener, CommandListener, TimerListener, CommunicationListener, UsageInformationAble {
|
||||
use UsageInformationTrait;
|
||||
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const VERSION = '0.200';
|
||||
const API_VERSION = '2013-04-16';
|
||||
const MIN_DEDIVERSION = '2014-04-02_18_00';
|
||||
const MIN_DEDIVERSION = '2017-03-23_18_00';
|
||||
const SCRIPT_TIMEOUT = 10;
|
||||
const URL_WEBSERVICE = 'https://ws.maniacontrol.com/';
|
||||
const SETTING_PERMISSION_SHUTDOWN = 'Shutdown ManiaControl';
|
||||
|
Loading…
Reference in New Issue
Block a user