language: php
sudo: false
cache:
  directories:
    - vendor
    - $HOME/.composer/cache
php:
  - 5.5
  - 5.6
  - 7.0
  - 7.2

matrix:
  include:
    - php: 5.5
      env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable'

before_script:
  - echo "xdebug.max_nesting_level=1000" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
  - if [[ $TRAVIS_PHP_VERSION = '5.6' ]]; then PHPUNIT_FLAGS="--coverage-clover=coverage.clover"; else PHPUNIT_FLAGS=""; fi
  - if [[ $TRAVIS_PHP_VERSION != '5.6' ]]; then phpenv config-rm xdebug.ini; fi  
  - composer self-update
  - composer update $COMPOSER_FLAGS

script: vendor/phpunit/phpunit/phpunit $PHPUNIT_FLAGS

after_script:
  - wget https://scrutinizer-ci.com/ocular.phar
  - if [[ $TRAVIS_PHP_VERSION = '5.6' ]]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
  
