hallernsk/php-project-lvl2

View on GitHub
src/Formatters.php

Summary

Maintainability
A
0 mins
Test Coverage
B
87%
<?php

namespace Differ\Formatters;

function format(array $data, string $format): string
{
    switch ($format) {
        case 'stylish':
            return Stylish\format($data);

        case 'plain':
            return Plain\format($data);

        case 'json':
            return Json\format($data);

        default:
            throw new \Exception("Incorrect output format $format");
    }
}