language: php

dist: trusty

php:
 - 7.2
 - 7.3

matrix:
 include:
  - php: 7.2
    env: COVERAGE=yes

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

before_script:
 - composer self-update
 - if [[ $COVERAGE == yes ]]; then curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter; fi
 - if [[ $COVERAGE == yes ]]; then chmod +x ./cc-test-reporter; fi
 - if [[ $COVERAGE == yes ]]; then ./cc-test-reporter before-build; fi

install:
 - composer install --prefer-source

script:
 - if [[ $COVERAGE != yes ]]; then composer test; fi
 - if [[ $COVERAGE == yes ]]; then composer testc; fi
 - if [[ $COVERAGE == yes ]]; then composer check-code; fi

after_script:
 - if [[ $COVERAGE == yes ]]; then ./cc-test-reporter after-build --coverage-input-type clover --exit-code $TRAVIS_TEST_RESULT; fi

notifications:
 email: false
