Slackwolf\Game\Formatter\OptionFormatter::format PHP Метод

format() публичный статический Метод

public static format ( Option $option ) : string
$option Slackwolf\Game\Option
Результат string
    public static function format(Option $option)
    {
        $rtn = "|_  " . $option->name . " ";
        switch ($option->optionType) {
            case OptionType::Bool:
                $rtn .= "on|off (" . ($option->value ? "on" : "off") . ")";
                break;
            case OptionType::Int:
                $rtn .= "intValue (" . $option->value . ")";
                break;
            case OptionType::String:
                $rtn .= "stringValue (" . $option->value . ")";
                break;
            case OptionType::StringArray:
                $rtn .= "add|remove stringValue (" . implode(', ', $option->value) . ")";
                break;
            case OptionType::UserArray:
                $rtn .= "add|remove @user (" . implode(', ', $option->value) . ")";
                break;
            default:
                $rtn .= "value (" . $option->value . ")";
                break;
        }
        return $rtn . "\t\t" . $option->helpText . "\r\n";
    }

Usage Example

Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function fire()
 {
     $help_msg = "Options\r\n------------------------\r\n";
     $help_msg .= "To set an option use !setOption Name Value.  The valid names and values are provided below for each option. The current value is indicated in parenthesis.\r\n";
     $help_msg .= "Available Options\r\n------------------------\r\n";
     foreach ($this->gameManager->optionsManager->options as $curOption) {
         /* @var \Slackwolf\Game\Option $curOption */
         $help_msg .= OptionFormatter::format($curOption);
     }
     $this->client->getDMByUserId($this->user)->then(function (DirectMessageChannel $dm) use($help_msg) {
         $this->client->send($help_msg, $dm);
     });
 }
All Usage Examples Of Slackwolf\Game\Formatter\OptionFormatter::format
OptionFormatter