sudo: false

language: php

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

matrix:
  include:
    - php: 5.6
    - php: 7
      env:
        - EXECUTE_CS_CHECK=true
        - EXECUTE_TEST_COVERALLS=true
    - php: 7.1
    - php: hhvm
  allow_failures:
    - php: hhvm

services:
  - redis-server

before_install:
  - if [[ $TRAVIS_PHP_VERSION != 'hhvm' ]]; then phpenv config-add ./tests/build/php.ini; fi;

install:
  - travis_retry composer install --no-interaction

script:
  - if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit --disallow-test-output --report-useless-tests --coverage-clover ./clover.xml ; else ./vendor/bin/phpunit --disallow-test-output ; fi
  - if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff --dry-run ; fi

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