Longman\TelegramBot\Commands\Command::getConfig PHP Method

getConfig() public method

Look for config $name if found return it, if not return null. If $name is not set return all set config.
public getConfig ( string | null $name = null ) : array | mixed | null
$name string | null
return array | mixed | null
    public function getConfig($name = null)
    {
        if ($name === null) {
            return $this->config;
        }
        if (isset($this->config[$name])) {
            return $this->config[$name];
        }
        return null;
    }

Usage Example

 public function testCommandWithConfigCorrectConfig()
 {
     $this->assertAttributeEquals(['config_key' => 'config_value'], 'config', $this->command_stub_with_config);
     $this->assertEquals(['config_key' => 'config_value'], $this->command_stub_with_config->getConfig(null));
     $this->assertEquals(['config_key' => 'config_value'], $this->command_stub_with_config->getConfig());
     $this->assertEquals('config_value', $this->command_stub_with_config->getConfig('config_key'));
     $this->assertEquals(null, $this->command_stub_with_config->getConfig('not_config_key'));
 }