language: php
dist: trusty
sudo: false

php:
  - 5.6
  - 7.0
  - 7.1
  - 7.2

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

before_script:
  # Deactivate xdebug
  - if [ -z "$KEEP_XDEBUG" ]; then rm -rfv /home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ; fi
  - composer install --ignore-platform-reqs

script:
  - ./vendor/bin/phpunit

jobs:
  include:

    - stage: Code style
      php: 7.1
      script:
        - ./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run
        - ./vendor/bin/phpcs --report-width=200 --report-summary  --report-full samples/ src/ tests/ --ignore=samples/Header.php --standard=PSR2 -n

    - stage: Coverage
      php: 7.1
      env: KEEP_XDEBUG=1
      script:
        - ./vendor/bin/phpunit --debug --coverage-clover coverage-clover.xml
      after_script:
        - wget https://scrutinizer-ci.com/ocular.phar
        - php ocular.phar code-coverage:upload --format=php-clover tests/coverage-clover.xml
