version: 2

jobs:
    build:
        macos:
            xcode: '11.4.0'
        steps:
            - checkout

            - restore_cache:
                keys:
                    - cache-{{ checksum "composer.json" }}

            - run: brew update
            - run: brew install php@7.4
            - run: echo "memory_limit = 512M" > $(brew --prefix)/etc/php/7.4/conf.d/memory.ini
            - run: curl -sS https://getcomposer.org/installer | php
            - run: php composer.phar global show hirak/prestissimo -q || php composer.phar global require --no-interaction --no-progress --optimize-autoloader hirak/prestissimo
            - run: php composer.phar install --optimize-autoloader --no-interaction --no-progress --no-suggest
            - run: php composer.phar info -D | sort

            - save_cache:
                key: cache-{{ checksum "composer.json" }}
                paths:
                    - ~/.composer
                    - ~/Library/Caches/Homebrew

            - run: vendor/bin/phpunit
            - run: PHP_CS_FIXER_FUTURE_MODE=1 php php-cs-fixer --diff --dry-run -v fix
