#!/usr/bin/env bash

function php-cs-fixer() {
  if [[ ! -e ./vendor/bin/php-cs-fixer ]]; then
    echo "The vendor/bin/php-cs-fixer file is missing. Did you install the dependencies?"
    exit 1
  fi

  vendor/bin/php-cs-fixer fix -v "$@"
  PHP_CS_CONFIG=legacy vendor/bin/php-cs-fixer fix -v "$@"
  PHP_CS_CONFIG=template vendor/bin/php-cs-fixer fix -v "$@"
}

function usage() {
  cat <<HEREDOC
Usage: ./run [task]
  php-cs-fixer  Run the PHP coding style fixer
HEREDOC
}

case "$1" in
  php-cs-fixer)
    php-cs-fixer "${@:2}"
    exit 0
  ;;
  *)
    usage
    exit 1
  ;;
esac