name: Coding Standards

on:
  pull_request:
  push:
    branches:
      - main
      - master

jobs:
  coding-standards:
    name: Coding Standards
    runs-on: ubuntu-latest

    env:
      PHP_CS_FIXER_VERSION: v2.17.3

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 7.4
          coverage: none
          tools: php-cs-fixer:${{ env.PHP_CS_FIXER_VERSION }}

      - name: Restore PHP-CS-Fixer cache
        uses: actions/cache@v2
        with:
          path: .php_cs.cache
          key: "php-cs-fixer"
          restore-keys: "php-cs-fixer"

      - name: Run PHP-CS-Fixer, version ${{ env.PHP_CS_FIXER_VERSION }}
        run: |
          php-cs-fixer fix --diff --diff-format=udiff --dry-run --verbose
