<?php

use Drupal\restaurant\Helper\Helper;

class SelectHelper extends Helper
{
  public function select($args)
  {
      //$arg[0] = name, arg[1] = options, arg[2] = values, arg[3] = selected
      $str = '<select name="' . $args[0];
      if (! empty ($arg[1])) {
        $str .= $this->htmlAttributes($arg[1]);
      }
      $str .= '">';

      foreach ($args[2] as $key => $val) {
        $str .= '<option ';
        if (! empty ($args[2])) {
          if ($key == $args[2]) {
            $str .= 'selected ';
          }
        }
        $str .= 'value="' . $key . '">' . $val . '</option>';
      }

      $str .= '</select>';
      return $str;
  }
}
