| <?xml version="1.0" encoding="UTF-8"?>
<project name="webapp" default="noop">
    
    <target name="noop"/>
    <property environment="env"/>
    
    <!-- By default, we assume all tools to be on the $PATH -->
    <condition property="ext" value=".bat">
        <os family="windows"/>
    </condition>
  
    <target name="phpunit" description="Run unit tests with PHPUnit">
        <exec executable="${basedir}/vendor/bin/phpunit${ext}" searchpath="true" resolveexecutable="true" failonerror="true" taskname="phpunit">
            <arg value="--configuration"/>
            <arg path="${basedir}/phpunit.xml"/>
        </exec>
    </target>
    
    <target name="phpunit-coverage" description="Run unit tests with PHPUnit with coverage">
        <delete dir="${basedir}/build/coverage"/>
        <mkdir dir="${basedir}/build/coverage"/>
        <exec executable="${basedir}/vendor/bin/phpunit${ext}" searchpath="true" resolveexecutable="true" failonerror="true" taskname="phpunit-coverage">
            <arg value="--configuration"/>
            <arg path="${basedir}/phpunit.xml"/>
            <arg value="--coverage-clover"/>
            <arg path="${basedir}/build/logs/clover.xml"/>
            <arg value="--coverage-html"/>
            <arg path="${basedir}/build/coverage"/>
        </exec>
    </target>
    
    <target name="php-cs-fixer" description="Code style fixer">
        <mkdir dir="${basedir}/build"/>
        <get src="https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.0.0/php-cs-fixer.phar" dest="${basedir}/build/php-cs-fixer.phar" skipexisting="true"/>
        <exec executable="php" searchpath="true" resolveexecutable="true">
            <arg value="${basedir}/build/php-cs-fixer.phar"/>
            <arg value="fix"/>
            <arg value="${basedir}/src/"/>
            <arg value="--rules=@PSR2"/>
            <arg value="--using-cache=no"/>
        </exec>   
        <exec executable="php" searchpath="true" resolveexecutable="true">
            <arg value="${basedir}/build/php-cs-fixer.phar"/>
            <arg value="fix"/>
            <arg value="${basedir}/tests/"/>
            <arg value="--rules=@PSR2"/>
            <arg value="--using-cache=no"/>
        </exec>   
    </target>
    
</project>
 |