language: php

cache:
  apt: true
  directories:
    - $HOME/.composer/cache

addons:
  apt:
    packages:
      - language-pack-ar
      - language-pack-fr
      - language-pack-sr
      - language-pack-zh-hans
      - language-pack-zh-hant
      - language-pack-yo

env:
  global:
    - setup=basic
    - coverage=false
    - xdebug=true
    - phpstan=false
    - laravel=false

sudo: false

services:
  - memcached
  - redis-server
  - mysql

before_install:
  - if [[ $laravel = 'true' ]]; then phpenv config-rm xdebug.ini || true; fi
  - if [[ $laravel = 'true' ]]; then echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
  - if [[ $laravel = 'true' ]]; then printf "\n" | pecl install -f redis; fi
  - if [[ $laravel = 'true' ]]; then travis_retry composer self-update; fi
  - if [[ $laravel = 'true' ]]; then mysql -e 'CREATE DATABASE forge;'; fi
  - if [[ $coverage = 'false' && $xdebug = 'true' ]]; then phpenv config-rm xdebug.ini; fi

install:
  - composer remove --no-update friendsofphp/php-cs-fixer
  - composer remove --no-update phpmd/phpmd
  - composer remove --no-update squizlabs/php_codesniffer
  - if [[ $phpstan != 'true' ]]; then travis_retry composer remove --no-update phpstan/phpstan; fi
  - if [[ $setup = 'nightly'  ]]; then travis_retry composer update --prefer-dist --no-interaction --no-suggest --ignore-platform-reqs; fi
  - if [[ $setup = 'basic'  ]]; then travis_retry composer update --prefer-dist --no-interaction --no-suggest; fi
  - if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-dist --no-interaction --no-suggest --prefer-stable; fi
  - |
    if [[ $setup = 'lowest' ]]; then
        travis_retry composer update --prefer-dist --no-interaction --no-suggest --prefer-stable --prefer-lowest
    fi

script:
  - if [[ $laravel != 'true' && $coverage = 'true' ]]; then phpunit --verbose --coverage-clover=coverage.xml --coverage-text; fi
  - if [[ $laravel != 'true' && $coverage != 'true' ]]; then composer phpunit; fi
  - if [[ $laravel != 'true' && $phpstan = 'true' ]]; then composer phpstan; fi
  - if [[ $laravel = 'true' ]]; then vendor/bin/multi-tester; fi

after_success:
  - if [[ $coverage = 'true' ]]; then bash <(curl -s https://codecov.io/bash); fi

branches:
  only:
    - gh-pages
    - /.*/

matrix:
  include:
    - php: 7.1.8
    - php: 7.1.9
    - php: 7.1.11
    - php: 7.1.15
    - php: 7.1.17
    - php: 7.1.20
    - php: 7.1.24
    - php: 7.1
    - php: 7.1
      env: setup=lowest
    - php: 7.1
      env: setup=stable

    - php: 7.2.0
    - php: 7.2.3
    - php: 7.2.5
    - php: 7.2.8
    - php: 7.2
    - php: 7.2
      env: setup=lowest
    - php: 7.2
      env: setup=stable

    - php: 7.3
      env: xdebug=false
    - php: 7.3
      env:
        - xdebug=false
        - setup=lowest
    - php: 7.3
      env:
        - xdebug=false
        - setup=stable
        - coverage=true
        - phpstan=true
    - php: nightly
      env:
        - xdebug=false
        - setup=nightly
    - php: 7.3
      env:
        - xdebug=false
        - setup=stable
        - coverage=false
        - phpstan=false
        - laravel=true
  fast_finish: true
  allow_failures:
    - php: 7.3
      env:
        - xdebug=false
        - setup=stable
        - coverage=false
        - phpstan=false
        - laravel=true

notifications:
  slack:
    secure: mdZBxjp18TYD4hOXKrj2mayveaUBj2fcgiVb1LOv1fiuonzhNwT5I5n795BNGpl1z76I8ZzD3MICbvigXs8QGMBkTnCriSEZNuyQUlAR972q+h02HmKM/j0d90S3tGbPh6PFGh0oo7ZCt0TAlHtNTGL0uyOwzJ26A+Sa5zA8HzN+y44KXTyMYRE/RXDkKB8460W+UFOVXsFw3pdXqeW6CbQY4A8hR8F0veBThfqrE/qXtmQ0MR97uuaDQDbJAiJuVe3DzIOcAdYwuqYbm3sgsomqsXONX7LyrrqXPguNDyM7XwkZUP6t9Nqvxz94HIJkYWASFNgOyysxOYqhgtAG7/xkT77D63IzxcsxLtfNSzOJwaP7xE3YHog082MR0ywdpZpjklmDdPhhiDfGaGRSHGJCqEMcW4QjFibLm3pnvxXoeTyY4Zx0hkCRqDlTYq9IMX6i3fVF4dZ+egOSJrd9BDXlnkyNy2C3z/5Ee6hfVoD53FT4l8zvRc+ip2tFQOzE1O81o8OYHOsF4DfcE0u1B/+ZeYihuFbJ8DMIBv8bUlZ76sQLQD0FAPzeKURDB2lTlUFODUH8ewPEuGbH6Bbao5bFoeWKvC6xTCuanpeU1xwJrzSvzMljqcEyZmOoqST776wCwS/qjY9yh8344VTZYHqGVY/L5DxjTbvSKpyHj2k=
