Kahlan\Reporter\Coverage\Exporter\CodeClimate::write PHP Method

write() public static method

Writes a coverage to an ouput file.
public static write ( array $options ) : boolean
$options array The option where the possible values are: -`'file'` _string_: The output file name.
return boolean
    public static function write($options)
    {
        $defaults = ['file' => null];
        $options += $defaults;
        if (!($file = $options['file'])) {
            throw new RuntimeException("Missing file name");
        }
        unset($options['file']);
        return file_put_contents($file, static::export($options));
    }

Usage Example

<?php

use filter\Filter;
use kahlan\reporter\Coverage;
use kahlan\reporter\coverage\exporter\CodeClimate;
$args = $this->args();
$args->argument('coverage', 'default', 3);
Filter::register('kahlan.coverage-exporter', function ($chain) {
    $reporter = $this->reporters()->get('coverage');
    if (!$reporter || !getenv('CODECLIMATE_REPO_TOKEN')) {
        return $chain->next();
    }
    CodeClimate::write(['collector' => $reporter, 'file' => 'codeclimate.json', 'branch' => getenv('TRAVIS_BRANCH') ?: null, 'repo_token' => getenv('CODECLIMATE_REPO_TOKEN')]);
    return $chain->next();
});
Filter::apply($this, 'reporting', 'kahlan.coverage-exporter');
require_once __DIR__ . '/spec/init.php';
All Usage Examples Of Kahlan\Reporter\Coverage\Exporter\CodeClimate::write