on:
  push:
  schedule:
  - cron: '0 0 * * *'

jobs:
  php-tests:
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        php: [7.4, 7.3, 7.2, 7.1, 7.0]
        dependency-version: [prefer-lowest, prefer-stable]
        os: [ubuntu-latest]

    name: PHP${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}

    steps:
    - name: Checkout code
      uses: actions/checkout@v1

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php }}
        extensions: mbstring

    - name: Install dependencies
      run: |
        composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest

    - name: Execute Unit Tests
      run: vendor/bin/phpunit

    - name: Check PSR-12 Codestyle
      run: vendor/bin/phpcs --standard=psr12 src/
      if: matrix.os == 'ubuntu-latest'