PhpBench\Report\Generator\EnvGenerator::generate PHP Метод

generate() публичный Метод

public generate ( SuiteCollection $suiteCollection, Config $config )
$suiteCollection PhpBench\Model\SuiteCollection
$config PhpBench\Registry\Config
    public function generate(SuiteCollection $suiteCollection, Config $config)
    {
        $document = new Document();
        $reportsEl = $document->createRoot('reports');
        $reportsEl->setAttribute('name', 'table');
        $reportEl = $reportsEl->appendElement('report');
        if (isset($config['title'])) {
            $reportEl->setAttribute('title', $config['title']);
        }
        if (isset($config['description'])) {
            $reportEl->appendElement('description', $config['description']);
        }
        foreach ($suiteCollection as $suite) {
            $tableEl = $reportEl->appendElement('table');
            $colsEl = $tableEl->appendElement('cols');
            foreach (['provider', 'key', 'value'] as $colName) {
                $col = $colsEl->appendElement('col');
                $col->setAttribute('name', $colName);
                $col->setAttribute('label', $colName);
            }
            $tableEl->setAttribute('title', sprintf('Suite #%s %s', $suite->getUuid(), $suite->getDate()->format('Y-m-d H:i:s')));
            $groupEl = $tableEl->appendElement('group');
            $groupEl->setAttribute('name', 'body');
            foreach ($suite->getEnvInformations() as $envInformation) {
                foreach ($envInformation as $key => $value) {
                    $rowEl = $groupEl->appendElement('row');
                    $cellEl = $rowEl->appendElement('cell', $envInformation->getName());
                    $cellEl->setAttribute('name', 'provider');
                    $cellEl = $rowEl->appendElement('cell', $key);
                    $cellEl->setAttribute('name', 'key');
                    $cellEl = $rowEl->appendElement('cell', is_bool($value) ? $value ? 'yes' : 'no' : $value);
                    $cellEl->setAttribute('name', 'value');
                }
            }
        }
        return $document;
    }