<?php

namespace Drupal\{{module}}\Controller;


{% if services is defined %}
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
{% set params = '' %}
{% for service in services %}use {{ service.class }};
{% set params = params ~ service.short ~ ' $' ~ service.machine_name %}
{% if loop.last == false %}
{% set params = params ~ ', '%}
{% endif %}
{% endfor %}
{% endif %}

class {{ name }} {% if services is defined%}implements ContainerInjectionInterface {% endif %}{

{% if services is defined %}
{% for service in services %}
  protected ${{service.machine_name}};
{% endfor %}

  public function __constructor({{params}}) {
{% for service in services %}
    $this->{{service.machine_name}} = ${{service.machine_name}};
{% endfor %}
  }

  public static function create(ContainerInterface $container){
    return new static(
{% for service in services %}
      $container->get('{{service.name}}'),
{% endfor %}
    );
  }
  {% endif %}

  /**
   * helloAction
   * @param  string $name Get
   * @return [type]       [description]
   */
  public function helloAction($name) {
    return "Hello" . $name . "!";
  }
}

<?php

namespace Drupal\{{module}}\Controller;


{% if services is defined %}
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
{% set params = '' %}
{% for service in services %}use {{ service.class }};
{% set params = params ~ service.short ~ ' $' ~ service.machine_name %}
{% if loop.last == false %}
{% set params = params ~ ', '%}
{% endif %}
{% endfor %}
{% endif %}

class {{ name }} {% if services is defined%}implements ContainerInjectionInterface {% endif %}{

{% if services is defined %}
{% for service in services %}
  protected ${{service.machine_name}};
{% endfor %}

  public function __constructor({{params}}) {
{% for service in services %}
    $this->{{service.machine_name}} = ${{service.machine_name}};
{% endfor %}
  }

  public static function create(ContainerInterface $container){
    return new static(
{% for service in services %}
      $container->get('{{service.name}}'){% if loop.last == false %},{% endif %}
{% endfor %}
    );
  }
  {% endif %}

  /**
   * helloAction
   * @param  string $name Get
   * @return [type]       [description]
   */
  public function helloAction($name) {
    return "Hello " . $name . "!";
  }
}

Remove comma on last injected service
Remove comma on last injected service
