language: php

php:
  - 5.6
  - 7.0
  - 7.4
  - 8.0

dist: xenial

before_script:
  - composer self-update
  - composer install --prefer-source --no-interaction $(if (( ${TRAVIS_PHP_VERSION:0:1} > 7 )); then echo --ignore-platform-reqs; else echo ""; fi)

script:
  - >-
    if (( ${TRAVIS_PHP_VERSION:0:1} < 8 )); then 
      XDEBUG_MODE=coverage ./vendor/bin/phpunit --whitelist ./src --coverage-text --coverage-clover=coverage.clover;
    else 
      ./vendor/bin/phpunit --whitelist ./src;
    fi

after_script:
  - if [[ ${TRAVIS_PHP_VERSION:0:1} == "7" ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
  - if [[ ${TRAVIS_PHP_VERSION:0:1} == "7" ]]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi