@ 2017-07-11T22:20:13Z <?php
class CommandFactory
{
private $commandMappings;
public function __construct(string $mappingFilename = 'default.json')
{
$mappingsJSON = file_get_content($mappingFilename);
$this->commandMappings = json_decode("{
'command' : {
'SYSTEMS' : {
'OS1' : {
'Version' : 'command string',
'Version2' : 'command string',
},
'OS2' : {
'Version' : 'command string',
'Version' : 'command string'
},
'COMMANDOPTIONS' : ['var1', 'var2', 'var3'],
},
'add-Firewall' : {
'SYSTEMS' : {
'Ubuntu' : {
'14' : 'command string',
'11' : 'command string',
},
'Redhat' : {
'13' : 'command string',
'11' : 'command string'
},
'COMMANDOPTIONS' : ['port',],
},
}", true);
}
public function getCommand(string $command, array $options): Command
{
$commandArray = $this->commandMappings[$command];
return new Command($commandArray, $options);
}
}
class Command
{
private $options;
private $mapping;
public function __construct($mappings, $options)
{
// check if options are are valid
// potentially map in options here?
}
public function view(string $os, $version): string
{
// validate $os and $version
$command = $this->mapping['SYSTEMS'][$os][$version]
//$command = str_replace(array_keys($options), $options, $command);
return $command;
}
}
// usage
$factory = new CommandFactory();
$firewallCommand = $factory->getCommand('add-Firewall', array['port' => 23]);
echo $firewallCommand->view('Ubuntu', '11');
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.1.7 0.003 0.017 17.09 7.1.6 0.026 0.019 34.96 7.1.5 0.027 0.017 34.60 7.1.4 0.033 0.008 34.25 7.1.3 0.036 0.008 34.32 7.1.2 0.029 0.013 34.69 7.1.1 0.014 0.007 16.31 7.1.0 0.014 0.008 16.46 7.0.20 0.006 0.013 16.54 7.0.19 0.014 0.006 16.26 7.0.18 0.011 0.014 15.84 7.0.17 0.012 0.010 16.11 7.0.16 0.008 0.011 16.11 7.0.15 0.005 0.015 16.11 7.0.14 0.010 0.011 16.27 7.0.13 0.010 0.010 16.24 7.0.12 0.007 0.013 16.08 7.0.11 0.011 0.008 16.13 7.0.10 0.008 0.013 16.04 7.0.9 0.015 0.008 16.01 7.0.8 0.006 0.016 16.10 7.0.7 0.011 0.009 16.32 7.0.6 0.007 0.012 15.96 7.0.5 0.010 0.010 15.96 7.0.4 0.003 0.016 16.21 7.0.3 0.009 0.011 16.37 7.0.2 0.006 0.013 16.12 7.0.1 0.005 0.014 16.30 7.0.0 0.010 0.012 16.25
preferences:dark mode live preview
138 ms | 1394 KiB | 7 Q