TrackManiaControl/application/core/Utils/CommandLineHelper.php

46 lines
900 B
PHP
Raw Normal View History

2014-05-01 20:15:47 +02:00
<?php
namespace ManiaControl\Utils;
2014-05-01 20:15:47 +02:00
/**
* Command Line Helper Class
2014-05-02 17:40:47 +02:00
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
2014-05-01 20:15:47 +02:00
*/
class CommandLineHelper {
/**
2014-08-02 20:51:48 +02:00
* Get the command line parameter value with the given name
2014-05-02 17:40:47 +02:00
*
2014-05-01 20:15:47 +02:00
* @param string $paramName
2014-06-26 11:07:53 +02:00
* @return string
2014-05-01 20:15:47 +02:00
*/
public static function getParameter($paramName) {
2014-05-02 17:40:47 +02:00
$paramName = (string)$paramName;
2014-08-02 20:51:48 +02:00
$params = self::getAllParameters();
foreach ($params as $param) {
$parts = explode('=', $param, 2);
2014-05-01 20:15:47 +02:00
if (count($parts) < 2) {
continue;
}
if ($parts[0] !== $paramName) {
continue;
}
return $parts[1];
}
return null;
}
2014-08-02 20:51:48 +02:00
/**
* Get all command line parameters
*
* @return array
*/
public static function getAllParameters() {
global $argv;
return (array)$argv;
}
2014-05-01 20:15:47 +02:00
}